当用户双击“按下”esc 键时,我想在 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
关于keyboard-shortcuts - 在 AutoHotkey 中检测双键按下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1794258/