Autohotkey:通配符ahk_class匹配

时间:2017-11-16 20:39:11

标签: autohotkey

我使用winspy来获取我的autohotkey宏的ahk_class。有时该应用程序有2 + ahk_classes与该程序相关联

示例:

HwndWrapper[program.exe;;1111-1111]
HwndWrapper[program.exe;;2222-2222]

如何使用winNotExist只是匹配两个名字?或者使用||OR等?

E.g。

F12::
IfWinNotExist, ahk_class "HwndWrapper.+"
    Run, AQ8.exe
GroupAdd, kjexplorers11, ahk_class "HwndWrapper.+" ;You have to make a new group for each application, don't use the same one for all of them!
if WinActive("ahk_exe AQ8.exe")
    GroupActivate, kjexplorers11, r
else
    WinActivate ahk_class ahk_class "HwndWrapper.+" ;you have to use WinActivatebottom if you didn't create a window group.
Return

1 个答案:

答案 0 :(得分:0)

我终于明白了。 SetTitleMatchMode, Regex

  

此命令会影响所有窗口命令的行为,例如: WinExist和WinActivate

然后编写一些类似javascript的正则表达式语句作为参数。

窗口命令的完整列表位于AHK site

enter image description here

脚本,修订

F12::
SetTitleMatchMode,RegEx
IfWinNotExist, ahk_class HwndWrapper.+
    Run, AQ8.exe
GroupAdd, kjexplorers11, ahk_class HwndWrapper.+ ;You have to make a new group for each application, don't use the same one for all of them!
if WinActive("ahk_exe AQ8.exe")
    GroupActivate, kjexplorers11, r
else
    WinActivate ahk_class ahk_class HwndWrapper.+ ;you have to use WinActivatebottom if you didn't create a window group.
Return

所以现在我可以遍历任何超过1个ahk_Class名称的应用程序。什么脚本的例子

enter image description here