我需要使用 Ctrl + 9 + 8 或 Ctrl + A 这样的热键 + B。
Autohotkey 文档 here表示不支持三个或更多键的组合。但是,支持 Alt + Ctrl + Shift + X 修饰键组合,其中 X 可以是字母数字字符。
最佳答案
KeyWait
ing 显示在另一个答案中,我想显示另一个选项,它使用 #If
和 GetKeyState()
.
您可以通过使用 #If
指令设置任何条件来创建上下文相关的热键。
在你的情况下,你想检查你的热键的第一个键是否被按下。
然后将最后一个键设置为热键。
#If, GetKeyState("Ctrl") ;start of context sensitive hotkeys
8 & 9::
MsgBox, % "Ctrl + 8 + 9 held down"
return
#If ;end of context sensitive hotkeys
;example of holding down even more keys
;is only going to work if your system can
;recognize this many keys at once
#If, GetKeyState("Ctrl") && GetKeyState("1") && GetKeyState("2") && GetKeyState("3") && GetKeyState("4") && GetKeyState("5")
6 & 7::
MsgBox, % "Ctrl + 1 + 2 + 3 + 4 + 5 + 6 + 7 held down"
return
#If
我是否推荐这种方法是另一回事。
如果您的脚本只是简单的热键或类似的东西,这是一个很好的方法。
但是,如果您的脚本比这更复杂,您可能会遇到 #If
可能导致的问题。更多关于 documentation 的信息.
基本上,只需尝试一下,如果遇到问题,也许可以考虑另一种方法。
关于automation - 如何使用 Autohotkey 创建三键组合热键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62614287/