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.
Parent/child window relationship Topic is solved
Parent/child window relationship
try it and see
...
...
- Delta Pythagorean
- Posts: 627
- Joined: 13 Feb 2017, 13:44
- Location: Somewhere in the US
- Contact:
Re: Parent/child window relationship
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
Re: Parent/child window relationship
From How to find "permanent" Unique ID / HWND of a window? or anything that is unique and permanent?For this to work, the window needs to have a unique set of controls.
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
...
...
Re: Parent/child window relationship Topic is solved
Try this:
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, 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
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
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Parent/child window relationship
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
...
...
Re: Parent/child window relationship
Your DllCall works good. I can get the class of the Owner window. Thanks a lot.
try it and see
...
...
Who is online
Users browsing this forum: Araphen, Google [Bot] and 285 guests