Ehr*_*ryk 6 conditional autohotkey conditional-statements
我一直在浏览AutoHotKey文档,我没有看到如何在上下文特定的热键中使用'或'.在我的设置中,Cygwin将使用ahk_class cygwin(当我使用上下文菜单时)或mintty(当我直接使用.bat或exe时)启动.
目前,我将热键复制到两个单独的块中,
#IfWinActive ahk_class cygwin
...
#IfWinActive
#IfWinActive ahk_class mintty
...
#IfWinActive
Run Code Online (Sandbox Code Playgroud)
有没有办法将它们结合起来?我试过了:
#IfWinActive ahk_class cygwin ahk_class mintty
#IfWinActive ahk_class || cygwin ahk_class mintty
#IfWinActive ahk_class or cygwin ahk_class mintty
#IfWinActive ahk_class cygwin || #IfWinActive ahk_class mintty
#IfWinActive ahk_class cygwin or #IfWinActive ahk_class mintty
#IfWinActive (ahk_class cygwin or ahk_class mintty)
#IfWinActive (ahk_class cygwin || ahk_class mintty)
#IfWinActive ahk_class cygwin|mintty
#IfWinActive ahk_class cygwin||mintty
Run Code Online (Sandbox Code Playgroud)
......而这些似乎都不起作用.这篇文章说明这可以通过组完成,但我正在寻找一种方法将它们组合在一个语句中.
好的,最后一个(并经过测试).
#If WinActive("ahk_class ExploreWClass") || WinActive("ahk_class CabinetWClass")
Run Code Online (Sandbox Code Playgroud)
哦,顺便说一句,我使用AutoHotKey_L,它支持#If!
好吧,我记得,在看到另一个例子之后:用多个ahk_class条目定义一个GroupName ....
GroupAdd, GroupName, ahk_class ExploreWClass
GroupAdd, GroupName, ahk_class CabinetWClass
#IfWinActive ahk_group GroupName
Run Code Online (Sandbox Code Playgroud)
您还可以尝试以下方法,我测试过并且它对我有用(AutoHotkey v1.1.14.01):
SetTitleMatchMode, REGEX
#IfWinActive (cygwin)|(mintty)
Run Code Online (Sandbox Code Playgroud)
这使用了正则表达式的内置 OR 机制。由于某种原因我无法让小组工作。