简体   繁体   English

无法使用AutoHotkey按住键

[英]Can't hold down a key with AutoHotkey

I have a simple script that doesn't seem to behave as expected: 我有一个似乎不符合预期的简单脚本:

^j::
  Send, {Down down}
  Sleep, 10000
  Send, {Down up}
Return

I would like it to hold the down arrow key for 10 seconds, and then release. 我希望按住向下箭头键10秒钟,然后松开。 Instead, it presses the down key once, and breaks the script until reload. 而是按一次向下键,然后中断脚本直到重新加载。 What am I doing wrong? 我究竟做错了什么?

Send documentation says: Send的文件说:

When a key is held down via the method above, it does not begin auto-repeating like it would if you were physically holding it down (this is because auto-repeat is a driver/hardware feature). 通过上述方法按住某个键时,它不会像您物理按下该键那样开始自动重复操作(这是因为自动重复是驱动程序/硬件功能)。

Use SetKeyDelay and specify the number of repetitions: 使用SetKeyDelay并指定重复次数:

SetKeyDelay, 30
Send {Down 333}

333 is approximately 10000/30 333是大约10000/30

Alternatively you can do it in a loop and check for other keys in order to stop sending Down key. 或者,您可以loop执行此操作并检查其他键,以便停止发送Down键。

Found a nice workaround, try some script like this (adjust the Mynumber variable to your liking and the Sleep aswell) 找到了一个不错的解决方法,尝试这样的脚本(根据自己的喜好和Sleep调整Mynumber变量)

a::
Mynumber = 10
While Mynumber > 0
{
Send {Down DOWN}
Sleep 10
Send {Down UP}
Mynumber--
}

According to documentation this should work: 根据文档,这应该起作用:

To hold down or release a key: Enclose in braces the name of the key followed by the word Down or Up. For example:

Send {b down}{b up}
Send {TAB down}{TAB up}
Send {Up down}  ; Press down the up-arrow key.
Sleep 1000  ; Keep it down for one second.
Send {Up up}  ; Release the up-arrow key.

docs about holding down keys: https://www.autohotkey.com/docs/commands/Send.htm 有关按住键的文档: https : //www.autohotkey.com/docs/commands/Send.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM