Gui Posted October 21, 2009 Share Posted October 21, 2009 Aye guys, in my bot I'm making, it has a For-To-Next loop. To stop that loop, I want a button to be pressed. So how would I do that? You can do "Func button2() " inside the FTN loop, so what can I do to make it so that if you press a button, it will exit that loop? Please reply. Gui. Link to comment Share on other sites More sharing options...
UnknownWarrior Posted October 21, 2009 Share Posted October 21, 2009 (edited) Aye guys, in my bot I'm making, it has a For-To-Next loop. To stop that loop, I want a button to be pressed. So how would I do that? You can do "Func button2() " inside the FTN loop, so what can I do to make it so that if you press a button, it will exit that loop? Please reply. Gui. If _IsPressed("") Then ExitLoop EndIf Search _IsPressed for correct usage. Edited October 21, 2009 by UnknownWarrior Link to comment Share on other sites More sharing options...
Gui Posted October 21, 2009 Author Share Posted October 21, 2009 That's a hotkey, if i'm correct, not a button. I'm well informed of that function, already. Thanks for your help though . Link to comment Share on other sites More sharing options...
Gui Posted October 21, 2009 Author Share Posted October 21, 2009 Aye guys, in my bot I'm making, it has a For-To-Next loop. To stop that loop, I want a button to be pressed. So how would I do that? You can do "Func button2() " inside the FTN loop, so what can I do to make it so that if you press a button, it will exit that loop? Please reply.Gui.EDIT: I have tried _ispressed, with hotkeys, non work. The loop doesn't allow any functions to work, while it's working. I can't close, or anything. It only stops when a number is reached,( the number of loops.). Link to comment Share on other sites More sharing options...
rliiack Posted October 23, 2009 Share Posted October 23, 2009 (edited) #include <ButtonConstants.au3> $Test = GUICreate("???", 625, 445, 192, 124) $Quit = GUICtrlCreateButton("Quit", 360, 232, 153, 65) GUISetState() While 1 ;infinte loop $msg=GUIGetMsg() If $msg = $Quit Then ExitLoop EndIf WEnd I used a while loop (because it is easier), but it has the same effect. Edited October 23, 2009 by rliiack My Projects:Smart Icons Link to comment Share on other sites More sharing options...
FuryCell Posted October 23, 2009 Share Posted October 23, 2009 GuiGetMsg creates a sleep which will slow down your loop. You could use OnEventMode like this. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $QuitLoop = 0 $Form1 = GUICreate("Form1", 218, 55, 192, 124) $Button1 = GUICtrlCreateButton("Kill Loop", 64, 24, 89, 25, $WS_GROUP) GUISetState(@SW_SHOW) GUICtrlSetOnEvent($Button1, "QuitLoop") While 1 If $QuitLoop = 1 Then ExitLoop Sleep(100) WEnd MsgBox(0, "", "The Loop has exited.") Func QuitLoop() Global $QuitLoop = 1 EndFunc ;==>QuitLoop HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now