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
Breaking a user defined loop with a hotkey??
Re: Breaking a user defined loop with a hotkey??
^k:: Reload
Re: Breaking a user defined loop with a hotkey??
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:
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.
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
Who is online
Users browsing this forum: ntepa and 111 guests