0
我有toggle
变量在#IfWinActive
块之外,但变量未用#IfWinActive
块初始化。如何切换一组热键?使用Autohotkey切换一组热键
toggle := false
f12::
toggle:=!toggle
SendInput {F12}
return
#IfWinActive ahk_class Chrome_WidgetWin_1
;toggle := false ;this doesn't do anything either
if (toggle) {
^a::SendInput {HOME}
}
#IfWinActive
您不能在条件块内分配正常热键,而且您不必。只需将你的热键直接放在'#IfWinActive ...'的下方。只有Chrome处于活动状态时才会触发它们。 – MCL
你能否详细说明你的第一个陈述?因为我知道你可以[使用另一个键切换一些热键](http://www.autohotkey.com/board/topic/41206-modal-vim/)(例如CapsLock),我想这样做。我不想让我的密钥因为触发Chrome而处于活动状态。如果你看到我的意图,当我按下F12并打开Developer Tool时,我试图触发vim键。 – Forethinker
他说你不能把你的热键'^ a :: SendInput'放在一个有条件的地方(在你的情况下是''if'')。您必须在条件之外定义热键,然后在其中处理切换变量。 –