Parent/child window relationship Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Parent/child window relationship

22 Jul 2017, 14:19

I have several windows on one process, and they each have a child window with the same title. How can I determine the parent window of this window when it is open? I.e., it would the the window directly behind it, because the parent window "owns" (?) it.
Also, when one of these child windows/dialog boxes are open, you cannot activate any other windows on that process, so there will never be more than one child window open at once.

Likely there is some way this can be done, but need advice. :D

Thanks in advance.
try it and see
...
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Parent/child window relationship

22 Jul 2017, 16:51

Use Hwnd with each window being different. It should work somewhat.

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Parent/child window relationship

22 Jul 2017, 18:40

For this to work, the window needs to have a unique set of controls.
From How to find "permanent" Unique ID / HWND of a window? or anything that is unique and permanent?
https://autohotkey.com/boards/viewtopic.php?t=20754

But HWND is not permanent, and these windows with identical titles have exactly the same controls. However, the list in the ListBox are different, but all changeable, so I would prefer to not base the code on that.

So I don't see what Hwnd would do for me?
try it and see
...
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Parent/child window relationship  Topic is solved

22 Jul 2017, 18:59

Try this:

Code: Select all

q::
WinGet, hWnd, ID, A
hWnd1 := DllCall("user32\GetAncestor", Ptr,hWnd, UInt,1) ;GA_PARENT = 1
hWnd2 := DllCall("user32\GetWindow", Ptr,hWnd, UInt,4) ;GW_OWNER = 4
WinGetClass, vWinClass1, % "ahk_id " hWnd1
WinGetClass, vWinClass2, % "ahk_id " hWnd2
MsgBox, % hWnd1 " " vWinClass1 "`r`n" hWnd2 " " vWinClass2
return
Another thing to be aware of is to check for WS_DISABLED := 0x8000000.

E.g. try this on Notepad, when the Open dialog is/isn't displayed.

Code: Select all

q::
WinGet, vWinStyle, Style, ahk_class Notepad
MsgBox, % !!(vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Parent/child window relationship

23 Jul 2017, 08:01

So there is way to do it. And I thought jeeswg might be someone who would know about it. Thanks for that bit of code. I will mess around with it later. today I am away from the computer.
try it and see
...
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Parent/child window relationship

24 Jul 2017, 11:08

Your DllCall works good. I can get the class of the Owner window. Thanks a lot.
try it and see
...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Google [Bot] and 285 guests