Hi,
As an example: Let's say you open Windows Explorer and from within its "Folder options" window.
Two questions:
01. The folder options window contains a few tabs and subsections with elements.
How do I get the hwnd of this window when the mouse is hovering over any element in this window?
02. How do I get the hwnd of the "root" window (the hwnd of the belonging Windows Explorer window) under the same assumption that the mouse is over any element in the folder options window?
Or more generalized:
How should this be done for any application (finding the hwnd of the window that the current hovered element belongs to and finding the hwnd of the main (if the current window is a child window) window)?
Tia,
Jacky
Get belonging hwnd?
Re: Get belonging hwnd?
Try this
Get hwnd from mouse pos:
Get root:
Get hwnd from mouse pos:
Code: Select all
p.q
GetCursorPos_(@p);
Debug WindowFromPoint_(p)
Code: Select all
GetAncestor_(hwnd,#GA_ROOT)
Re: Get belonging hwnd?
Thank you, Mijikai!
E.g. if the folder options window is open and the mouse is inside of it, it returns
the hwnd of that folder options window and not the hwnd of the window it "belongs too" (the main Windows Explorer window)
This works fine.Get hwnd from mouse pos
This doesn't get me the hwnd of the window that the (sub) window belongs too.GetAncestor_(hwnd,#GA_ROOT)
E.g. if the folder options window is open and the mouse is inside of it, it returns
the hwnd of that folder options window and not the hwnd of the window it "belongs too" (the main Windows Explorer window)
Re: Get belonging hwnd?
For the 'root' window u can also try one of these Apis:
Code: Select all
;GetWindow_() -> with #GW_OWNER
;GetPartent_()
Re: Get belonging hwnd?
A typoMijikai wrote:For the 'root' window u can also try one of these Apis:
Code: Select all
;GetWindow_() -> with #GW_OWNER ;GetPartent_()
Code: Select all
GetParent_()
Re: Get belonging hwnd?
Bisonte wrote: A typo
Re: Get belonging hwnd?
Thanks Mijikai,
is what I was looking for
Code: Select all
GetWindow_() -> with #GW_OWNER