简体   繁体   English

热键不与发送命令一起循环

[英]Hotkey doesn't loop with Send command

I have this code, and i want to whenever i hold ctrl+n it will click and drag.我有这段代码,我想每当我按住 ctrl+n 时它都会单击并拖动。 It doesn't loop with the Send commands in place.它不会与适当的发送命令一起循环。 It only runs once, unless i let go of ctrl and n and press again.它只运行一次,除非我让 go 的 ctrl 和 n 并再次按下。 If i comment them out the hotkey loops perfectly fine when i hold it down.如果我将它们注释掉,当我按住它时,热键循环就很好了。 Heres my script:这是我的脚本:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
; SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


^n::
CoordMode, Mouse, Screen
Send {LButton down} ;if i comment these two out it works fine
MouseMove, 0, 30, 20, R
Send {LButton up} ; ditto
return

The problem was ctrl key.问题是 ctrl 键。 When pressed down it stops new execution of hotkey.按下它会停止热键的新执行。 I tried it without ctrl prefix and used just n:: and it worked fine.我在没有 ctrl 前缀的情况下尝试了它,只使用了 n:: 并且效果很好。 It also works if you press ctrl+n then release it then press it again.如果您按 ctrl+n 然后释放它然后再次按它,它也可以工作。 Anyways when you add Hotkey Modifier $ sign in front it works as you wanted.无论如何,当您在前面添加 Hotkey Modifier $ 符号时,它会按您的意愿工作。

Hotkey Modifier $ explanation:热键修饰符 $ 说明:

This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself.这通常仅在脚本使用发送命令发送组成热键本身的键时才需要,否则可能会导致它自己触发。 The $ prefix forces the keyboard hook to be used to implement this hotkey, which as a side-effect prevents the Send command from triggering it. $ 前缀强制使用键盘钩子来实现这个热键,它的副作用是阻止发送命令触发它。 The $ prefix is equivalent to having specified #UseHook somewhere above the definition of this hotkey. $ 前缀相当于在此热键定义上方的某个位置指定了#UseHook。

More info: https://www.autohotkey.com/docs/Hotkeys.htm更多信息: https://www.autohotkey.com/docs/Hotkeys.htm

$^n::
CoordMode, Mouse, Screen
Send {LButton down}
MouseMove, 0, 30, 20, R
Send {LButton up}
return

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

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