Page 1 of 1
Ending the output of a macro on any input
Posted: 04 Dec 2022, 08:41
by The Spirit
How can I stop the output of a lengthy macro on any input whatsoever?
Let's assume I have the following simplified example:
Code: Select all
a::
MouseMove, 100, 200
Sleep, 50
Send, g
Sleep 100
MouseMove, 300, 400
Sleep 50
Send, k
Sleep 100
Send, i
return
Can I tell it to stop on the spot when I press another button? If I were to press another macro for example after 150 ms then they would overlap, potentially ruining both of them.
Thank you
Re: Ending the output of a macro on any input Topic is solved
Posted: 04 Dec 2022, 08:53
by mikeyww
You can reload the script, or set a "stop variable" and then check that variable in your hotkey subroutine.
Re: Ending the output of a macro on any input
Posted: 07 Dec 2022, 17:10
by The Spirit
How would I go about it in an efficient way? The only way I can think of is having a variable, let's call it b, whose value is then switched at the start of every macro while the command that I want to be interruptable uses exactly that variable in a While equals something condition. That means I have to put b everywhere, and that still wont work on some input like left click, which I do not use a macro for.
Is there a command I could use which I only need to mention once? Something like
Code: Select all
a::
b:=GO
while (b = GO)
{
MouseMove, 100, 200
Sleep, 50
Send, g
Sleep 100
MouseMove, 300, 400
Sleep 50
Send, k
Sleep 100
Send, i
Sleep 50
b:=STOP
}
return
ON ANYTHING::
b:=STOP
return
Re: Ending the output of a macro on any input
Posted: 07 Dec 2022, 19:04
by mikeyww
Code: Select all
#InstallMouseHook
a Up::
While (A_PriorKey = "a") {
MouseMove, 300, 700
Sleep, 50 * (A_PriorKey = "a")
If (A_PriorKey = "a")
Send g
Sleep, 100 * (A_PriorKey = "a")
}
Return