Autohotkey 自动热键-检测双重按下AltGr
我想检测AltGr上的双重按压 根据文件:Autohotkey 自动热键-检测双重按下AltGr,autohotkey,double-click,Autohotkey,Double Click,我想检测AltGr上的双重按压 根据文件: ; Example #4: Detects when a key has been double-pressed (similar to double-click). ; KeyWait is used to stop the keyboard's auto-repeat feature from creating an unwanted ; double-press when you hold down the RControl key to mod
; Example #4: Detects when a key has been double-pressed (similar to double-click).
; KeyWait is used to stop the keyboard's auto-repeat feature from creating an unwanted
; double-press when you hold down the RControl key to modify another key. It does this by
; keeping the hotkey's thread running, which blocks the auto-repeats by relying upon
; #MaxThreadsPerHotkey being at its default setting of 1.
; Note: There is a more elaborate script to distinguish between single, double, and
; triple-presses at the bottom of the SetTimer page.
~RControl::
if (A_PriorHotkey <> "~RControl" or A_TimeSincePriorHotkey > 400)
{
; Too much time between presses, so this isn't a double-press.
KeyWait, RControl
return
}
MsgBox You double-pressed the right control key.
return
;示例#4:检测何时双击某个键(类似于双击)。
; KeyWait用于阻止键盘的自动重复功能创建不需要的重复
; 按住RControl键时双击可修改另一个键。它是通过
; 保持热键的线程运行,通过依赖
; #MaxThreadsPerHotkey的默认设置为1。
; 注意:有一个更详细的脚本来区分单、双和双
; 在SetTimer页面底部按三次。
~r控制::
如果(主热键“~RControl”或主热键>400)
{
;两次按压之间的时间太长,因此这不是一次双重按压。
按键等待,遥控
返回
}
MsgBox您双击右控制键。
返回
AltGr实际上是LControl和RAlt的组合。所以,对于AltGr,脚本应该是这样的:
~LControl & RAlt::
if (A_PriorHotkey <> "~LControl & RAlt" or A_TimeSincePriorHotkey > 400)
{
click
KeyWait, LControl & RAlt
return
}
click 2
return
~LControl&RAlt::
如果(主热键“~LControl&RAlt”或主热键>400)
{
点击
键盘等待、LControl和RAlt
返回
}
点击2
返回
但当我尝试加载此脚本时,AutoHotkey会出现错误:
也许有一种方法可以为组合键创建别名。如评论中所述,KeyWait一次只能等待一个键(不是热键)。您只需要等待RAlt被释放,而不是LCtrl和RAlt的组合 这项工作:
~LControl & RAlt::
if (A_PriorHotkey <> "~LControl & RAlt" or A_TimeSincePriorHotkey > 400)
{
KeyWait, RAlt
return
}
MsgBox Double-click
return
Keywait不能与多个键一起使用。这里有一些论坛帖子可能会有所帮助。(, )
<^RAlt::
KeyWait RAlt
KeyWait RAlt, D T0.4
if ErrorLevel
MsgBox Single
else
MsgBox Double
return