How to check all windows with WinExist?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kashmirLZ
Posts: 27
Joined: 06 Oct 2022, 23:27

How to check all windows with WinExist?

Post by kashmirLZ » 04 Feb 2023, 01:07

I have to detect the presence of a specific window based on title and size.

Code: Select all

WinSizeExist(Name, _W, _H){
    if WinExist(Name){
        WinGetPos, , , W, H
        if (W = _W and H = _H)
            return true 
    }
    return false
}

if WinSizeExist("Common Title", 200, 100)
    MsgBox, "You got it!"
It works fine if there's only 1 window with that title present, but there are 2 windows with that title...

WinExist()
This function returns the unique ID (HWND) (as hexadecimal integer) of the first matching window (0 if none).


Then I'm never finding that specific-size window I'm looking for, even if it's present.

So what's the approach here? I need to check through all the windows with WinExist, and check their H/W.
Ideas?

just me
Posts: 9406
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to check all windows with WinExist?

Post by just me » 04 Feb 2023, 04:14

Code: Select all

WinGet, WinList, List, %Name%

kashmirLZ
Posts: 27
Joined: 06 Oct 2022, 23:27

Re: How to check all windows with WinExist?

Post by kashmirLZ » 05 Feb 2023, 05:17

just me wrote:
04 Feb 2023, 04:14

Code: Select all

WinGet, WinList, List, %Name%
> Each ID number is stored in a variable whose name begins with OutputVar's own name (to form a pseudo-array), while OutputVar itself is set to the number of retrieved items (0 if none)

wat 👀

(when AHKv2?)

just me
Posts: 9406
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to check all windows with WinExist?

Post by just me » 05 Feb 2023, 07:03

The Docs wrote:Example #2.

Post Reply

Return to “Ask for Help (v1)”