Reputation: 101
SetTimer, Test, 1000
Return
Test:
Send, a
Sleep, 3000
Send, b
Sleep, 3000
Send, c
Sleep, 3000
Return
1::
Send, x
SetTimer, Test, Off
Return
If I press "1" on 5th second, result will be: "axbc"
How to make timer stop running its content immediately, so in case above result would be "ax"?
Upvotes: 0
Views: 1046
Reputation: 2344
One way of doing it by checking whether the hotkey has been triggered (via the state
variable) after every sleep cycle
;state:=0 ;state is zero by default
SetTimer, Test, 1000
Return
Test:
Send, a
Sleep, 3000
if(state)
return
Send, b
Sleep, 3000
if(state)
return
Send, c
Sleep, 3000
Return
1::
Send, x
SetTimer, Test, Off
state := 1
Return
Upvotes: 1