【发布时间】:2019-03-20 09:30:28
【问题描述】:
我正在编写这个脚本。
#Persistent
Random , timerval , 7800 , 8460
SetTimer, PressTheKey, %timerval%
Return
PressTheKey:
Send, {d}
Return
这是每 8~ 秒按下“d”的基本间隔。有用。问题是,如果按下另一个键,例如鼠标右键,“d”将不会被触发,我将不得不等待剩余的持续时间。
我需要让脚本等待鼠标右键未被按下,或者每 10 毫秒左右运行一次检查以检查鼠标右键是否被按下,如果不是,它可以发送, {d}。
所以,我正在考虑使用 GetKeyState()、KeyWait 或 While 循环来解决这个问题。
#Persistent
Random , timerval , 7800 , 8460
SetTimer, PressTheKey, %timerval%
Return
GetKeyState, state, RButton
if state = D
KeyWait, RButton
PressTheKey:
Send, {d}
Return
我尝试了这个和其他的,但我无法将其投入使用,我不是编码专家,但我正在努力学习。
有人可以帮我解决这个问题吗?
编辑:按住键一段时间可以解决此问题。
#Persistent
Random , timerval , 7800 , 8460
Random , timerval2 , 180 , 250
SetTimer, PressTheKey, %timerval%
Return
PressTheKey:
Send, {t down}
Sleep, %timerval2%
Send, {t up}
Return
F1::
Pause
Suspend
return
【问题讨论】:
标签: key autohotkey auto