3

I used winspy to grab an ahk_class for my autohotkey macro. Sometimes that application has 2+ ahk_classes associated with that program

Example:

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

How can I use winNotExist to simply just match both names? Or perhaps use a ||, OR etc?

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
Vincent Tang
  • 3,758
  • 6
  • 45
  • 63
  • Try [SetTitleMatchMode RegEx](https://autohotkey.com/docs/commands/SetTitleMatchMode.htm) OR create a group of those two ahk_classes using [GroupAdd](https://autohotkey.com/docs/commands/GroupAdd.htm) and `IfWinNotExist, ahk_group my Group`. – user3419297 Nov 16 '17 at 21:41
  • I don't understand how settitlematchmode works. Documentation is lacking in good examples.How does it know to apply it to my ahk_class statements seen here? – Vincent Tang Nov 17 '17 at 16:12

1 Answers1

3

I finally figured it out. SetTitleMatchMode, Regex.

This command affects the behavior of all windowing commands, e.g. WinExist and WinActivate

Then write some javascript-like regex statements as arguments.

The full list of window commands is on AHK site

enter image description here

Script, revised

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

So now I can cycle through any application with more than 1 ahk_Class name. Example of what script does

enter image description here

Vincent Tang
  • 3,758
  • 6
  • 45
  • 63
  • I'd use "HwndWrapper_Group" instead of "kjexplorers11" to make clear that it concerns a windows group of that app or class. – user3419297 Nov 17 '17 at 16:48