Page 1 of 1

WinActive for many similar windows?

Posted: 23 Apr 2019, 11:39
by Peter2
(I suppose the answer will be a half-liner ..)

I want to start a script only when some special windows are active - so I think "WinActive" is the right was.
All windows are different, but similar. The ahk_class begins always with "" - see attachment.
Should be simple, but I'm failing ... :oops:

What's the right code?

Thanks and have a fine evening?

Re: WinActive for many similar windows?

Posted: 26 Apr 2019, 09:45
by Peter2
No ideas? Maybe I described it more complicated then it is ....

WinActive should check all ahk_classes which begin with a defined string and ends with unknown strings, like ...


Re: WinActive for many similar windows?

Posted: 26 Apr 2019, 11:57
by joefiesta
1. If you want the script to start by itself when some particular window becomes active, you would

a. use a WinWait command to wait for the particular window to exist. You would specify Ahk_class for the Wintitle parameter and use SettitleMatchMode to handle a regular expression (which I can't help you with) to specify a pattern-matched ahk_class value.

2. If you want to manually kick off the script and have it do something if some particular window exists, you would do the same thing as above, but change the WinWait command to a WinExist() command and continue accordingly.

3. You could also use a WinGet command to create a list of windows matching certain criteria, loop through the list to see if a desired window exists and, again, continue accordlingly.