Mat*_*ock 26 autohotkey keyboard-shortcuts keyboard-events
当用户双击"按下" esc键时,我想在AutoHotkey中触发一个事件.但是,如果不是双按(例如在一秒钟的空间内),让逃逸按键进入应用程序焦点.
我该怎么做呢?
到目前为止我已经想出了这个,但是我无法弄清楚如何检查第二个退出键按下:
~Esc::
Input, TextEntry1, L1 T1
endKey=%ErrorLevel%
if( endKey != "Timeout" )
{
; perform my double press operation
WinMinimize, A
}
return
Run Code Online (Sandbox Code Playgroud)
Mat*_*ock 34
在AutoHotkey文档中找到答案!
; 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
Run Code Online (Sandbox Code Playgroud)
所以对我来说:
~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
Run Code Online (Sandbox Code Playgroud)