how to stop a function

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hieveryone
Posts: 43
Joined: 28 Nov 2022, 01:31

how to stop a function

Post by hieveryone » 30 Nov 2022, 00:25

so pretend i got
press a to move mouse 100 times, and i want to stop it mid way with a hotkey\
the closest i could find is exitapp , which im pretty sure would stop all,butwhat if we want to \ press a key to stop it now but like the code, we can press a anytime to turn it back on, like a switch


thankyou

Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: how to stop a function

Post by Rohwedder » 30 Nov 2022, 01:11

Hallo,
try:

Code: Select all

q::
SetTimer, MouseMove, 200
Counter := 100
Return
\::SetTimer, MouseMove, Off
a::SetTimer, MouseMove, On
MouseMove:
IF Counter:= Max(--Counter, 0)
	MouseMove, 5, 0,, R
Else SetTimer, MouseMove, Off
Return

Post Reply

Return to “Ask for Help (v1)”