Jump to content

Recommended Posts

Posted

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.

Posted (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 by UnknownWarrior
Posted

That's a hotkey, if i'm correct, not a button. I'm well informed of that function, already. Thanks for your help though :).

Posted

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.).

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...