2

Ok my code has the following which works:

^m::Send M text{enter}
    Return

^s::Send S text{enter}
    Return

^t::Send T text{enter}
    Return

Now I want to be able to add something like the following (this way it doesn't work):

^m & ^t:: Send M and T text{enter}
    Return

^m & ^s:: Send M and S text{enter}
    Return

^t & ^s:: Send T and S text{enter}
    Return

I want AHK to take all three sequences like Ctrl+S does one thing and Ctrl+M does another but Ctrl+S+M does a different third action.

There is a similar post to this here: AutoHotKey key SEQUENCE, not just single-key hotkey

Syscall
  • 19,327
  • 10
  • 37
  • 52
  • Uh, I don't get it. Does your code not work for you? What doesn't it do for you? – bgmCoder Jul 31 '13 at 03:41
  • Sorry edited in the explanation. – Aristides Colon-Castillo Jul 31 '13 at 04:45
  • 1
    This really sounds like hotstrings to me. Have you considered using them instead of hotkeys? Furthermore, I wouldn't recommend using `CTRL + LETTER` hotkeys, since they almost always block some shortcut in many programs. E.g. `^s` is the standard save shortcut in editors; `^t` is the *new tab* shortcut in browsers, and so on. – MCL Jul 31 '13 at 13:35
  • Yea i already switched it to alt instead, but I had the same situation so I didn't feel like editing. Read up hotstrings. Really kool stuff will use it since it works for one of the things I'm doing. However, it's not exactly what I wanted. Because I wanted this to work for any action not just text. – Aristides Colon-Castillo Aug 01 '13 at 00:00
  • What do you mean by "any action"? Hotstring labels are able to execute any kind of code. – MCL Aug 01 '13 at 00:29
  • Oh. Ok. It's just that the AHK link I found only mentions text replacement. http://www.autohotkey.com/docs/Hotstrings.htm – Aristides Colon-Castillo Aug 02 '13 at 02:48

1 Answers1

1

If you don't find a fitting solution, you might want to try the workaround which I've been using.

Note: the following does not include any hotkey triggers like ^m::, the problem is being solved with the hotkey-command and fitting label names, which actually look like a hotkey trigger (^m:)

hotkey, ^m, ^m, On
hotkey, ^t, ^m, On

return

^m_and_^t:  ; will also be called from ^t & ^m
Send M and T text{enter}
triggered = true
return

^m_and_^s:
Send M and S text{enter}
triggered = true
return

^t_and_^s:
Send T and S text {enter}
triggered = true
return

^m:
triggered = false
hotkey, ^t, ^m_and_^t, On
hotkey, ^s, ^m_and_^s, On
loop
{
    getkeystate, isDown, m, P
    if isDown = U
        break
}
hotkey, ^t, ^t, On
hotkey, ^s, ^m_and_^s, Off ; -> ^s will keep its natural function

if triggered = false
{
    Send M text{enter}
}
return

^t:
triggered = false
hotkey, ^s, ^t_and_^s, On
hotkey, ^m, ^m_and_^t, On
loop
{
    getkeystate, isDown, t, P
    if isDown = U
        break
}
hotkey, ^m, ^m, On
hotkey, ^s, ^m_and_^s, Off ; -> ^s will keep its natural function
if triggered = false
{
    Send T text{enter}
}
return
phil294
  • 10,038
  • 8
  • 65
  • 98