Detect a double key press in AutoHotkey

后端 未结 2 1650
天命终不由人
天命终不由人 2020-12-15 16:59

I\'d like to trigger an event in AutoHotkey when the user double \"presses\" the esc key. But let the escape keystroke go through to the app in focus if it\'s not

2条回答
  •  难免孤独
    2020-12-15 17:35

    With the script above, i found out that the button i wanted to detect was being forwared to the program (i.e. the "~" prefix).

    This seems to do the trick for me (i wanted to detect a double "d" press)

    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
    

    Source

提交回复
热议问题