How to find out if a child gui exists?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
newbieforever
Posts: 506
Joined: 24 Aug 2016, 03:34

How to find out if a child gui exists?

Post by newbieforever » 30 Aug 2017, 15:30

Hi! My new newbie problem:

In my script child guis of a window are generated and destroyed. In a certain situation I have to know if a specific child gui exists.

My first attempt was to give each child gui a specific title to be able later to find out if the gui exists, like this:

Code: Select all

Gui 123: Show, , Gui123
;;;
If WinExist(Gui123)
MsgBox Yes, the specific child gui Gui123 exists.
But obviously WinExist() cannot find child guis.

How this can be done? Thank you very much in advance.

Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: How to find out if a child gui exists?

Post by Nightwolf85 » 30 Aug 2017, 15:42

Look into LastFoundExist

Code: Select all

Gui, Test:Show, , Gui123 
;Gui, Test:Destroy ; Try uncommenting an running again.
;;;
GUI, Test:+LastFoundExist
If WinExist()
	MsgBox Yes, the specific GUI 'test' exists.
Else
	MsgBox No, the specific GUI 'test' doesn't exists.
ExitApp
Edited to add destroy, to show it works if you create then destroy as well.

newbieforever
Posts: 506
Joined: 24 Aug 2016, 03:34

Re: How to find out if a child gui exists?

Post by newbieforever » 30 Aug 2017, 16:11

@Nightwolf85: Many many thanks, it works perfectly! I will use this!

(In the meantime I discovered another solution. Since my child guis contain controls (buttons), and this controls seems to belong to the parent window, I can check if I get a position of such a control in the parent window by ControlGetPos...)
Last edited by newbieforever on 30 Aug 2017, 22:31, edited 1 time in total.

newbieforever
Posts: 506
Joined: 24 Aug 2016, 03:34

Re: How to find out if a child gui exists?

Post by newbieforever » 30 Aug 2017, 22:17

Unfortunately an additional question:

The +LastFoundExist (or ControlGetPos) method work if only one parent window is involved. (I wrote: "child guis of a window are generated and destroyed".)

But what if a script generates and destroys child guis in more than one parent windows?

Post Reply

Return to “Ask for Help (v1)”