Autohotkey `1 键序列

Autohotkey `1 键序列

在 MSword 中我想设置

`1

作为触发脚本的键序列,但我在 MSword 中还有其他带有热键的脚本

1

和按键序列

11    ; (one pressed twice fast)

代码如下

; The following hotkeys work only if MS-WORD is the active window:
#If WinActive("ahk_exe WINWORD.EXE")    ; (1)

1::
if 1_presses > 0
{
    1_presses += 1
    SetTimer Key1, 300
    return
}
1_presses = 1
SetTimer Key1, 300
return

Key1:
SetTimer Key1, off
if 1_presses = 2
  SendInput, BYE
else
  SendInput, HELLOW
1_presses = 0
return

如何在不干扰其他热键的情况下设置“1 个键序列触发器”???

谢谢高级。

答案1

#If WinActive("ahk_exe WINWORD.EXE") 

    ; SC029 is the scancode of the key "`"

    ; SC029::
    ; KeyWait, SC029
    ; return

    SC029 Up::
    Send {SC029}
    return

    ; press 1 while you're holding down the "`"-key, to send a
    SC029 & 1:: Send a

    1::
    ; press 1 in less than 300 ms after pressing the "`"-key, to send b
    If (A_PriorHotKey = "SC029 Up" AND A_TimeSincePriorHotkey < 300)
    {
        Send {BS}b
        return
    }
    ; otherwise:
    if 1_presses > 0
    {
        1_presses += 1
        SetTimer Key1, 300
        return
    }
    1_presses = 1
    SetTimer Key1, 300
    return

    Key1:
    SetTimer Key1, off
    if 1_presses = 2
      SendInput, BYE
    else
      SendInput, HELLOW
    1_presses = 0
    return

#If

相关内容