AutoHotKey - how to send control and same key multiple times

喜夏-厌秋 提交于 2020-01-15 05:05:08

问题


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


来源:https://stackoverflow.com/questions/47637177/autohotkey-how-to-send-control-and-same-key-multiple-times

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!