【发布时间】:2015-10-10 01:55:12
【问题描述】:
是否可以使用 AutoHotKey 创建与状态相关的热键?我知道在使用 #IfWinActive 时可以在依赖状态下创建某些热键,但是在热键本身内部创建热键怎么样?
示例
F1::
Gui, Show, center center h500 w500, Just a window
return
F2::
MsgBox, 0, F2, You have pressed F2 inside the F1 hotkey
return
return
这里的问题是F2不依赖于状态,一按就会触发。
可能的解决方案
F1::
state := true
Gui, Show, center center h500 w500, Just a window
return
#If (state = true)
{
F2::
MsgBox, 0, F2, You have pressed F2 inside the F1 hotkey
return
}
GUIclose:
Gui, destroy
state := false
return
return
这是一个可能的解决方案,效果很好。但是,有没有比这种方式更简单的解决方案?
【问题讨论】:
-
据我所知,没有更好的方法。我会说你几乎把它钉牢了,代码看起来很干净。干得好。
标签: state autohotkey hotkeys