【发布时间】:2013-12-03 16:07:26
【问题描述】:
我目前有一个脚本反复按下鼠标左键,直到脚本被中断。要启动和停止脚本,请按下 ALT+2。如何让它以 ALT+2 开始,但按任意键停止?
#MaxThreadsPerHotkey 3
!2:: ; ALT+2 hotkey
#MaxThreadsPerHotkey 1
if KeepWinZRunning
{
KeepWinZRunning := false ;
return ;
}
; Otherwise:
KeepWinZRunning := true
Loop
{
ToolTip, Press ALT+2 again to stop.
Sleep 100
Send, {VK01 down}{VK01 up}
Sleep 100
if not KeepWinZRunning
break ; Break out of this loop.
}
KeepWinZRunning := false ; Reset in preparation for the next press of this hotkey.
ToolTip
return
ExitApp
F12::ExitApp
【问题讨论】:
-
1) 使用 timers 而不是 endless 循环,它们为(伪)多线程提供了更好的支持。 2) Input command 是您正在寻找的。不过,请仔细查看选项。
-
MCL 是对的。计时器还为您提供了同时运行线程甚至中断计时器线程的选项。 MCL 以前帮过我。
标签: autohotkey