AHK:通过具有重复键的序列的不同热键

时间:2013-07-31 02:09:34

标签: keyboard-shortcuts autohotkey

好的,我的代码具有以下功能:

^m::Send M text{enter}
    Return

^s::Send S text{enter}
    Return

^t::Send T text{enter}
    Return

现在我希望能够添加如下内容(这种方式不起作用):

^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

我希望AHK采取所有三个序列,例如 Ctrl + S 做一件事 Ctrl + M 做另一个但是 Ctrl + S + M 做了不同的第三个动作。

此处有类似的帖子:AutoHotKey key SEQUENCE, not just single-key hotkey

1 个答案:

答案 0 :(得分:1)

如果您找不到合适的解决方案,可能需要尝试我一直在使用的解决方法。

注意:以下包含^m::之类的热键触发器,问题正在通过hotkey - 命令和拟合标签名称,实际上看起来像热键触发器(^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