Unicode 自动热键重复按键序列,检测修改器的上键和下键

Unicode 自动热键重复按键序列,检测修改器的上键和下键,unicode,keyboard-shortcuts,autohotkey,Unicode,Keyboard Shortcuts,Autohotkey,与封面相似,我尝试绑定两个键序列 理想情况下,我希望将Alt向下,-,-,-,Alt向上绑定到em破折号(-),将Alt向下,-,-,Alt向上绑定到en破折号(–) 我所做的几乎适用于em破折号,但不完全适用: ; 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}

与封面相似,我尝试绑定两个键序列

理想情况下,我希望将Alt向下,-,-,-,Alt向上绑定到em破折号(-),将Alt向下,-,-,Alt向上绑定到en破折号(–)

我所做的几乎适用于em破折号,但不完全适用:

; 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

em-dash序列的工作方式类似于Alt+-,-,-,而不是我试图匹配的。我不知道如何只测试Alt DOWN和Alt UP。en破折号序列完全无法绑定,因为
-已绑定。

请查看此代码:

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

它似乎做得很好。该代码通过每次按下Alt+-时计数来工作。同时,会生成一个伪线程,等待Alt被释放,然后根据计数器发送相应的
破折号。

您不想使用它有什么特别的原因吗?例如,将键入的
--
转换为em破折号,并将
--
转换为en破折号。@elliotden如果我在编程中经常使用
--
,那就太好了!是否有关于
SetTimer
KeyWait
的API文档?谷歌总是返回几年前的论坛帖子,这些帖子没有多大帮助。@travis我刚读到你想避免使用热字符串,因为它们在使用减量运算符时会被触发。你知道吗,你可以使用
#If
#IfWin…
生成上下文相关的热字符串?不幸的是,我在相同的应用程序中使用并需要破折号进行编程。