Comman Continue Starts the Loop Over Autohotkey
how do you set a hotkey to reset the same script or to break a loop
what i have will start a loop sequence but i need to to be able to stoped with either another hotkey or the same hotkey to end it. and then be able to restart it at a later time.
^x:: loop { send, 2 sleep 9000 send, 3 sleep 5000 } return ^c:: exitapp
can anyone give me some pointers or a topic to try to search for on this issue?
#1 - Posted 31 May 2009 - 08:07 PM
- Back to top
Read the FAQ :!: It is a good place to start:
<!-- m -->http://www.autohotke.../FAQ.htm#repeat<!-- m -->
#2 - Posted 31 May 2009 - 08:21 PM
- Back to top
how do you set a hotkey to reset the same script or to break a loop
what i have will start a loop sequence but i need to to be able to stoped with either another hotkey or the same hotkey to end it. and then be able to restart it at a later time.
^x:: loop { send, 2 sleep 9000 send, 3 sleep 5000 } return ^c:: exitapp
can anyone give me some pointers or a topic to try to search for on this issue?
^x:: continue := true loop { send, 2 sleep 9000 send, 3 sleep 5000 if continue = false break } return ^b:: continue := false ^c:: exitapp
maybe something like this?
#3 - Posted 31 May 2009 - 08:33 PM
- Back to top
^x:: continue := true loop { WinGet, thirstid, List, Thirst IfWinActive, Thirst ControlSend,, {4}, ahk_id %thirstid2% Sleep 10 ControlSend,, {5}, ahk_id %thirstid2% Sleep 10 ControlSend,, {3}, ahk_id %thirstid2% Sleep 10 if continue = false break } return ^c:: continue := false
is my current exact script
ctrl + x starts but ctrl + c doesnt break the script
there are 2 instances of a program i use called thirst open and the one i do not have active i want it to send the script to it does but i need a way to break the script and i cant seem to figure this out
and pause did not work either
^x:: loop { WinGet, thirstid, List, Thirst IfWinActive, Thirst ControlSend,, {4}, ahk_id %thirstid2% Sleep 10 ControlSend,, {5}, ahk_id %thirstid2% Sleep 10 ControlSend,, {3}, ahk_id %thirstid2% Sleep 10 } return ^c::pause
the loop never gets broken
ive tride placeing it with in the loop but it just runs it once that way.
#4 - Posted 31 May 2009 - 08:59 PM
- Back to top
#MaxThreadsPerHotkey 3 #z:: #MaxThreadsPerHotkey 1 if KeepWinZRunning { KeepWinZRunning := false return } KeepWinZRunning := true loop { WinGet, thirstid, List, thirst IfWinActive, thirst ControlSend,, {4}, ahk_id %thirstid2% Sleep 10 ControlSend,, {5}, ahk_id %thirstid2% Sleep 10 ControlSend,, {3}, ahk_id %thirstid2% Sleep 10 if not KeepWinZRunning break } KeepWinZRunning := false return
isnt working the way i thought it should either
it starts but wont break
#5 - Posted 31 May 2009 - 09:14 PM
- Back to top
#MaxThreadsPerHotkey 3 KeepWinZRunning := true #z:: loop { WinGet, thirstid, List, thirst IfWinActive, thirst ControlSend,, {4}, ahk_id %thirstid2% Sleep 10 ControlSend,, {5}, ahk_id %thirstid2% Sleep 10 ControlSend,, {3}, ahk_id %thirstid2% if KeepWinZRunning = false break } Esc:: KeepWinZRunning := false return
#6 - Posted 31 May 2009 - 11:22 PM
- Back to top
still wont break and i copied exactly what you posted
#7 - Posted 31 May 2009 - 11:48 PM
- Back to top
and you're pressing Esc to break the loop?
#8 - Posted 01 June 2009 - 12:34 AM
- Back to top
yes
#9 - Posted 01 June 2009 - 01:09 AM
- Back to top
you might want to start a new file, just to be sure you are running the one you think you are running.
also, pepper your code with msgbox to see if the esc hotkey is running, or use tooltip to keep updating so you can see a variable while the script is running.
#10 - Posted 01 June 2009 - 04:39 AM
- Back to top
$F1:: ; Make the F1 key into a hotkey (the $ symbol facilitates the "P" mode of GetKeyState below).
Loop ; Since no number is specified with it, this is an infinite loop unless "break" or "return" is encountered inside.
{
if not GetKeyState("F1", "P") ; If this statement is true, the user has physically released the F1 key.
break ; Break out of the loop.
; Otherwise (since the above didn't "break"), keep clicking the mouse.
Click ; Click the left mouse button at the cursor's current position.
}
return
#11 - Posted 07 November 2013 - 07:07 PM
- Back to top
Source: https://www.autohotkey.com/board/topic/41264-hotkey-to-break-a-loop/
0 Response to "Comman Continue Starts the Loop Over Autohotkey"
Post a Comment