开始&使用按钮停止脚本循环操作

时间:2015-03-20 15:23:01

标签: autohotkey

脚本应该如下:

按下' C':开始/停止脚本

鼠标左键:开始/停止循环

循环内部:按住鼠标左键的同时,重复鼠标左键直到我抬起手指。

  • 每次点击后鼠标都会返回到屏幕中央。

另外,鼠标在每次单击后移动X像素,我的脚本非常慢。 它点击..点击..点击而不是ClickClickClick :(。

我现在把它改成了这个,但是鼠标按钮总是被激活,即使没有按住它,我也不能用C来停止/启动脚本。

HotKey, ~$*LButton, myLButtonAction ; Activate the hotkey by default
return

~c::    ; configure a Hotkey: c will enable / disable your LButton actions
HotKey, ~$*LButton, toggle  ; ON / OFF
return

myLButtonAction:    ;cnote: this is NOT a hotkey, it's a label
Loop
{
    Click
    Sleep 7,516  ;your loop actions (see question code)
}
return  ; don't forget your returns at the end of a label / hotkey

1 个答案:

答案 0 :(得分:2)

看起来您需要使用Hotkey命令。

x := (A_ScreenWidth // 2)
y := (A_ScreenHeight // 2)
HotKey, ~$*LButton, myLButtonAction ; Activate the hotkey by default
setMouseDelay, 0
setKeyDelay, 0
return

~c::    ; configure a Hotkey: c will enable / disable your LButton actions
HotKey, ~$*LButton, toggle  ; ON / OFF
return

myLButtonAction:    ; note: this is NOT a hotkey, it's a label

Loop                 ;loop the script until broken
{ ;loop start
GetKeyState, var, LButton, P ;Get the state of Lbutton
If var = U                            ;has it been released?
    Break       ;its been released so break the loop
;Send {LButton}  ;It hasnt been released so send another Click
Click %x%, %y%
Sleep 100 ;time between presses, after sleep return to the top of the loop
} ;loop end

return  ; don't forget your returns at the end of a label / hotkey

  

我的脚本很慢。它点击..点击..点击而不是ClickClickClick :(

setMouseDelay, 0加入auto-execution section。我已经在上面的代码示例中做了这个。

相关问题