2

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

^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

4

1 回答 1

1

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

注意:以下不包括任何热键触发器,例如^m::,问题正在通过热键命令和合适的标签名称解决,实际上看起来像热键触发器(^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
于 2015-01-18T17:35:36.877 回答