Подтвердить что ты не робот

Обнаружение двойного нажатия клавиши в AutoHotkey

Я хотел бы вызвать событие в AutoHotkey, когда пользователь дважды нажимает клавишу esc. Но пусть нажатие клавиши перехода переходит в приложение в фокусе, если оно не двойное нажатие (скажем, в течение секунды).

Как мне это сделать?

Я придумал это до сих пор, но я не могу понять, как проверить, чтобы второй клавиша escape-клавиши нажала:

~Esc::

    Input, TextEntry1, L1 T1
    endKey=%ErrorLevel%

    if( endKey != "Timeout" )
    {
        ; perform my double press operation
        WinMinimize, A
    }
return
4b9b3361

Ответ 1

Найден ответ в Документация AutoHotkey!

; Example #4: Detects when a key has been double-pressed (similar to double-click).
; KeyWait is used to stop the keyboard 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 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

Ответ 2

С помощью script выше я узнал, что кнопка, которую я хотел обнаружить, была запрограммирована на программу (то есть префикс "~" ).

Это похоже на трюк для меня (я хотел обнаружить двойное нажатие "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

Источник