热键不会使用发送命令循环

  • 本文关键字:命令 循环 autohotkey
  • 更新时间 :
  • 英文 :


我有这段代码,只要我按住ctrl+n,它就会点击并拖动。它不会在"发送"命令到位的情况下循环。它只运行一次,除非我放开ctrl和n并再次按下。如果我把它们注释掉,当我按住热键时,热键循环非常好。这是我的脚本:

#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

问题出在ctrl键上。按下时,将停止热键的新执行。我尝试了不带ctrl前缀的方法,只使用了n::,效果很好。如果你按下ctrl+n,然后松开它,然后再按下它,它也会起作用。不管怎样,当你在前面添加热键修饰符$符号时,它会按照你的意愿工作。

热键修饰符$解释:

只有当脚本使用"发送"命令发送组成热键本身的键时,这通常才是必要的,否则可能会导致热键自身触发。$prefix强制使用键盘挂钩来实现此热键,这会作为副作用阻止Send命令触发它。$prefix相当于在该热键定义之上的某个位置指定了#UseHook。

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

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

最新更新