WinActive for many similar windows?

Get help with using AutoHotkey and its commands and hotkeys
Peter2
Posts: 243
Joined: 21 Sep 2014, 14:38
Location: CH

WinActive for many similar windows?

23 Apr 2019, 11:39

(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 "WindowsForms10.Window.8.app........" - see attachment.
Should be simple, but I'm failing ... :oops:

What's the right code?

Thanks and have a fine evening?
Peter2
Attachments
ahk_class_dialogue.png
ahk_class_dialogue.png (19.18 KiB) Viewed 258 times
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
Peter2
Posts: 243
Joined: 21 Sep 2014, 14:38
Location: CH

Re: WinActive for many similar windows?

26 Apr 2019, 09:45

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 ...

my.program.12
my.program.hey
my.program.23x-8
my.program.abc123.89.d
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
joefiesta
Posts: 287
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: WinActive for many similar windows?

26 Apr 2019, 11:57

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.

Return to “Ask For Help”

Who is online

Users browsing this forum: Kobaltauge and 43 guests