简体   繁体   English

自动热键,切换:按住 Shift,每秒单击并释放 LButton

[英]Auto HotKey, Toggle: Hold Shift, Click and release LButton every second

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.我正在尝试制作一个包含Shift的 AutoHotkey 脚本,当它持有它时,我需要鼠标每秒单击并释放。 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 .在一定时间行为之后的这个循环最好通过调用SubroutineSetTimer function 来实现。

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.此外,由于您的脚本按住 Shift键,因此您还需要在按下Shift + Home时调用热键,以便将其关闭。


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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM