How to exit loop with the same button?

01/31/2015 20:09 huang_kaijie#1
Okay, so i will skip the gui code

Here is my main code

Quote:
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_Ready()
Case $Checkbox1
_Hack()
EndSwitch
WEnd

Func _Ready()
While 1
ControlSend(title, "", "", "{5}")
WEnd
EndFunc
and i want to exit the loop, how to do it ?
with the same button and the separate button :handsdown:
01/31/2015 21:39 alpines#2
If you want to exit the loop simple add ExitLoop after a Button-Case to do so.
02/01/2015 05:00 huang_kaijie#3
Quote:
Originally Posted by alpines View Post
If you want to exit the loop simple add ExitLoop after a Button-Case to do so.
can't, i tried exitloop a few times but it still run the loop

i tried


Quote:
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_Ready()
Case $Button2
ExitLoop
Case $Checkbox1
_Hack()
EndSwitch
WEnd

Func _Ready()
While 1
ControlSend(title, "", "", "{5}")
WEnd
EndFunc
02/01/2015 13:11 alpines#4
Which loop do you want to exit. The GUI-loop or the While 1 - ControlSend - WEnd Loop?
If you want to exit the ControlSend loop you have to enable GUIOnEventMode and transfer the event of $Button2 into a function where you set a variable true / false which gets checked every time in the ControlSend loop.
02/05/2015 02:31 yangc10#5
check this link out (might get you started) [Only registered and activated users can see links. Click Here To Register...]
02/26/2015 14:48 Strew#6
Bin neu in AutoIt aber so würe ich es probieren.
Pseudo Code:

Erzeuge einen Button o.ä.

Button Event:

Code:
Local $isRunning = False

If ($isRunning == False)
{

isRunning = true;

}else { 

isRunning = false;

}

while (isRunning == true)
{
; Hier den Codeinhalt
}
03/01/2015 19:54 Clonko#7
Do it like alpines said or get a condition from a variable instead of 1. Like

PHP Code:
Func _Ready()
While 
$running True
ControlSend
(title"""""{5}")
WEnd
EndFunc 
03/02/2015 17:37 KDeluxe#8
Do not use a second loop.
Code:
Global $sendKey = False

While Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $sendKey = Not $sendKey
        Case $Checkbox1
            _Hack()
    EndSwitch
    
    If $sendKey Then
        ControlSend("title", "", "", "{5}")
    EndIf
WEnd
10/25/2015 13:34 deniz454545#9
Quote:
Originally Posted by KDeluxe View Post
Do not use a second loop.
Code:
Global $sendKey = False

While Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $sendKey = Not $sendKey
        Case $Checkbox1
            _Hack()
    EndSwitch
    
    If $sendKey Then
        ControlSend("title", "", "", "{5}")
    EndIf
WEnd


I was just wondering if there is a program that i can make a bot for 4story because none of these auto click or auto keyboard (autoit included) working during in the game windows.You are a wise guy lol if you have a second to spare for an answer i would be appreciate. :)