AutoHotKey - how to send control and same key mult

2019-07-10 17:00发布

问题:

Specifically I want to hold down the control key, and press the m key, let go of m but keep control held down, and then press m again, which will trigger the function. More generically I'd like to know the syntax for telling autohotkey to read the same key multiple times

How do I do that?

I can do it with a single m like this

^m::
  Send, The text i want to send
Return

So far I have tried

^m m::
  Send, The text i want to send
Return

^m&m::
  Send, The text i want to send
Return

^mm::
  Send, The text i want to send
Return

All of which are illegal

回答1:

What about this:

; Depending on how many times a key combination was pressed, 
; execute different commands:

^m::
    ctrl_m_count++          ; start counter
    SetTimer ctrl_m_action, -50
return

ctrl_m_action:
    KeyWait, Ctrl
    If (ctrl_m_count = 1)
        MsgBox, ctrl_m_action 1
    If (ctrl_m_count = 2)
        MsgBox, ctrl_m_action 2
    ; ...
    ctrl_m_count := 0       ; reset  counter
return