Helena,您的脚本现在执行的操作如下。一旦脚本启动,它将开始每 150 毫秒发送一次 [Z] 和 [向下箭头]。这与当时正在运行的应用程序无关。你写你想循环发送代码,你想切换这个开/关。
这是一个更接近您的目标的示例。
#Persistent
F8:: ; This is your [F8] Toggle hotkey
If Toggle:=!Toggle ; Here you "test" the value of the variable "toggle" and after testing switch it to the opposite (true/false)
SetTimer, Trigger, -1 ; This is to create a separate thread for the loop. -1 means start in 1 ms but only do this one time, not every 1 ms's.
return
Trigger:
While (Toggle)
{
Send, +z{Down} ; + is the shift key, thus +z makes captial Z
Sleep, 500 ; Wait 500 ms (1/2 a second)
Send, +{z Down} ; Press Shift z Down. This will NOT start a repeat like ZZZZZZZZZZZZZZZZ
Sleep, 500 ; Wait 500 ms (1/2 a second)
Send, +{z Up} ; Lift Shift z Up
Sleep, 1 ; Required. Without it The F8 keypress to toggle off can not be read anymore
}
Return