AHK 的自动点击器,仅当我按 F9 时点击并按住控件

Auto Clicker for AHK that clicks and holds down control, only while i press F9

我需要一个 AHK 中的脚本,它可以为我正在使用的软件自动单击并同时按住控制键。我希望能够将该操作绑定到喜欢 F9

我找到了自动点击的脚本,但是它们是切换的,我不知道如何添加同时按住控件的功能。

q::
auto = true
send, {CONTROL DOWN}
while(auto){
    mouseclick, left, "X-Cord","Y-Cord"
    if GetKeyState(q)
      auto =true    
}
send, {CONTROL UP}
return

因为你不能运行同时执行 2 个命令,所以这应该可行。
如果你想根据你的用途更精确,
这样会更好:

q::
x := ;place your desired coordinates in these two variables.
y :=
f1::
 {
     mousegetpos, start_x, start_y
     auto = true
     send, {CONTROL DOWN}
     while(auto){
       mouseclick, left, %x%, %y%, 1, 0
       if GetKeyState(q)
         auto =true 
    }
    send, {CONTROL UP}
    mousemove, %start_x%, %start_y%, 0
 }
return

这将获取您的光标位置,尽快将光标移动到某个点,按住控件,单击鼠标左键,松开控件,return 到原始位置。

Use 'q' to start and terminate

这样比较紧凑。请注意,这也是使用 ctrl+F9 的设置,因为一旦按下控制,F9 将不会关闭自动点击,因为它认为您正在按下 ctrl+F9。它会点击你鼠标所在的位置,但如果你想点击特定位置,你可以添加坐标。我在那里睡了 50 毫秒,但可以根据您的需要进行修改。

f9::
^f9::
Send , % ( bT := !bT ) ? "{ctrl down}" : ""
While( bT )
{
    Click ; Clicks wherever your mouse is. Add coordinates if you need a specific pos.
    Sleep , 50
}
Send , {ctrl up}
Return