AutoHotkey ― 响应连续两次按下Esc或者Ctrl事件

键盘的快捷键一天天都不够用, 今天想用连续按下两次ESC或者Ctrl这样的条件, 来触发自定义事件.

(如同google desktop search那样)

 

再下面的帖子里面找到了正解, 以后用得着, 记录在这里.

Detect a double key press in AutoHotkey

 

响应连续两次按下Ctrl键, 弹出对话框提示

; 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键, 最小化Windows活动窗口

~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

 

 

 

 

你可能感兴趣的:(thread,windows,Google,活动)