AutoHotkey重复键序列,检测修饰符的KEYUP和KEYDOWN

tra*_*vis 2 unicode autohotkey keyboard-shortcuts

此问题涵盖的内容类似,我正在尝试绑定两个键序列.

理想情况下,我想结合Alt DOWN,-,-,-,Alt UP一个破折号( - )和Alt DOWN,-,-,Alt UP一个短破折号( - ).

我几乎为em-dashes工作但不完全:

; Em-dash
!-::
Input Key, L1
if Key=-
Input Key, L1
if Key=-
Send {ASC 0151}
return 

; En-dash
;!-::
;Input Key, L1
;if Key=-
;Send {ASC 0150}
;return
Run Code Online (Sandbox Code Playgroud)

该破折号序列就像Alt+ -,-,-,而不是我想要匹配.我不确定如何只测试Alt DOWNAlt UP.en-dash序列完全失败,因为!-已经绑定了.

MCL*_*MCL 5

看看这个:

dashCount := 0

!-::
    dashCount++
    if(dashCount = 1) {
        SetTimer, WaitForAlt, -1
    }
return

WaitForAlt:
    KeyWait, Alt
    if(dashCount = 2) {
        Send {ASC 0150}
    } else if(dashCount = 3) {
        Send {ASC 0151}
    }
    dashCount := 0
return
Run Code Online (Sandbox Code Playgroud)

它似乎做得很好.代码通过计算每次Alt+ -按下来计算.同时,生成等待Alt释放的伪线程,然后dash根据计数器发送适当的伪线程.