Breaking a user defined loop with a hotkey??

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wcarwile
Posts: 1
Joined: 22 Oct 2015, 06:50

Breaking a user defined loop with a hotkey??

22 Oct 2015, 06:53

I know this is probably asked a lot and I searched for about 15 minutes but couldn't find anything that I understood. Basically I have a simple macro script that creates a GUI for the user to input how many times to loop through the code. Sometimes it messes up and in these cases I want to be able to hit a hotkey so that the script is broken. Right now my code is as follows. What do I need to add in order to make CTRL+K into a hotkey to stop the loop? Any help is very much appreciated! Thank you :) \


^j::

Gui, Add, text, , Enter #:
Gui, Add, Edit, vNum
Gui, Add, Button, default, OK
Gui, Show
Return

GuiClose:
ButtonOK:
Gui, Submit

loop, %Num%
{
Sleep,1000
Send, {Down}
Send, {Down}
Send, {Down}
Send, {Right}
Send, {Enter}
Sleep, 1000
Send, ^f
Send, M251
Send, {Enter}
Send, {Esc}
Send, {Right}
Send, M236
Send, {Enter}
Send, ^f
Send, M99
Send, {Enter}
Send, {Esc}
Send, {Right}
Send, M236
Send, {Enter}
Sleep, 250
Send, !{F4}
Sleep, 250
Send, {Enter}
Sleep, 3500
Send, {Down}
Send, {Enter}
}

Gui, Destroy
Return
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Breaking a user defined loop with a hotkey??

22 Oct 2015, 12:26

The reload approach with this script isn't going to work unless you just minimize the GUI.

A couple more approaches are going to be ^k::Suspend or to set a flag with a hotkey and have your script check for the flag. Example:

Code: Select all

Loop
{
Send {Left}
Sleep 250
If flag=1
   Break
}
return

^k::flag:=1
This latter approach is not so hot when you have to check it many times throughout a loop because it keeps adding to the length of the overall loop, but it's an option.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], RussF and 237 guests