I'm trying to make an AutoHotkey script that holds Shift , and while it's holding it I need the mouse to click and release every second. This is what I have come up with so far.
Home::
KeyDown := !KeyDown
If KeyDown
SendInput {Shift down}, Click, Sleep 2000
Else
SendInput {Shift up}
Return
This loop after a certain amount of time behavior is best implemented with a SetTimer function invoking a Subroutine .
Additionally, since your script holds down the Shift key, you would need to also have the hotkey be invoked whenever Shift + Home is pressed as well, so that it can be turned off.
Final Code:
Home::
+Home:: ;Alternative hotkey definition that invokes on Shift+Home
KeyDown := !KeyDown
if (KeyDown){
SendInput {Shift down}
gosub, clickSubroutine ;To trigger the first click immediately
SetTimer, clickSubroutine, 1000 ;To trigger clicks after every 1000 ms (1 second)
}
else{
SendInput {Shift up}
SetTimer, clickSubroutine, Off ;Turn off the clickSubroutine Loop
}
Return
clickSubroutine:
Click
return
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.