如何打开和关闭一组键绑定? [英] How to toggle a set of keybinds on and off?
问题描述
我正在尝试建立一组按键组合,我可以通过按一下按钮来打开和关闭这些按键组合,但是却无法在任何地方找到任何示例.
I am trying to set up a group of keybinds that I can toggle on and off with a single button press but haven't been able to find any examples anywhere.
当我按下^ NumpadSub时,我希望^ NumpadSub切换这些不同的键绑定以打开和关闭它们.
I want ^NumpadSub to toggle these different keybinds to turn them on and off when I press ^NumpadSub.
q::w
z::s
w::up
s::down
有人可以帮助我设置代码吗?
Can anyone help on how I would set up the code to do so?
推荐答案
当这些是唯一的时,您可以再添加一个热键:
When these are the ONLY ones, you could add one more hotkey:
^NumpadSub::Suspend
这将暂停所有热键(用于切换开/关暂停的热键除外)
This will suspend ALL hotkeys (except the one that is used for toggling suspend on/off)
否则,您将必须使用实际的热键功能( http://www.autohotkey .com/docs/commands/Hotkey.htm ),您可以打开/关闭热键,但是热键功能引用标签:(转到地址).
Otherwise you would have to use the actual hotkey function (http://www.autohotkey.com/docs/commands/Hotkey.htm) which allows you to turn hotkeys on/off, but the hotkey function refers to labels: (go to addresses).
如果您只想让这些键在使用一个特定的应用程序(游戏)时以某种方式起作用,则可以使用#IfWinActive命令.
If you want to ONLY have these keys act a certain way when you use ONE particular application (Game), you can use the #IfWinActive command.
例如
SetTitleMatchMode, 2
#IfWinActive, Notepad ; Start of Notepad specific keys.
a::Send, Haha
b::SoundBeep, 500, 500
#IfWinActive ; End of Notepad specific keys.
在这种情况下,请检查这是否适合您!我在w和s前面添加了$符号,因为按q和z会触发w和s的执行
In that situation, Check out if this works for you! I added $ signs in front of w and s because hitting q and z would trigger the execution of w and s
Hotkey, q , MyQ, On
Hotkey, z , MyZ, On
Hotkey, $w , MyW, On
Hotkey, $s , MyS, On
Return
^NumpadSub::
KeyToggle:=!KeyToggle
Hotkey, q , % (KeyToggle ? "Off": "On")
Hotkey, z , % (KeyToggle ? "Off": "On")
Hotkey, $w , % (KeyToggle ? "Off": "On")
Hotkey, $s , % (KeyToggle ? "Off": "On")
Return
MyQ:
SendInput, w
Return
MyZ:
SendInput, s
Return
MyW:
SendInput, {Up}
Return
MyS:
SendInput, {Down}
Return
这篇关于如何打开和关闭一组键绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!