检测AutoHotkey中的双键按
问题描述:
我想在用户双击“按下”键时触发AutoHotkey中的事件。但如果不是双击(比如在一秒钟内),让逃生按键进入应用程序。检测AutoHotkey中的双键按
我该如何去做这件事?
我想出这个到目前为止,但我不知道如何来检查第二回避按键:
~Esc::
Input, TextEntry1, L1 T1
endKey=%ErrorLevel%
if(endKey != "Timeout")
{
; perform my double press operation
WinMinimize, A
}
return
答
发现在AutoHotkey documentation答案!
; 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
所以对于我的情况:
~Esc::
if (A_PriorHotkey <> "~Esc" or A_TimeSincePriorHotkey > 400)
{
; Too much time between presses, so this isn't a double-press.
KeyWait, Esc
return
}
WinMinimize, A
return
答
有了上面的脚本,我发现我想检测按钮正在forwared到程序(即“〜”前缀) 。
这似乎这样的伎俩,我(我想检测双“d”记者)
d::
keywait,d
keywait,d,d t0.5 ; Increase the "t" value for a longer timeout.
if errorlevel
{
; pretend that nothing happened and forward the single "d"
Send d
return
}
; A double "d" has been detected, act accordingly.
Send {Del}
return
的AutoHotkey有一个最好的Windows CHM帮助过的文件! – 2012-12-07 03:39:19
对于那些正在寻找处理双击的人(就像我一样)。这个答案同样适用于'〜LButton'。 – 2015-06-19 08:44:35