Jump to content
Sign in to follow this  

Get GUI handle from Control handle

Recommended Posts


Hello there :)

I'm trying to get the handle of the GUI the mouse is currently over. I found two approaches for doing that, but both won't fit my needs ..
First Thing you can do is a DLL Call

DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1))

Second is using the WinAPI

Local $g_tStruct = DllStructCreate($tagPOINT)
DllStructSetData($g_tStruct, "x", MouseGetPos(0))
DllStructSetData($g_tStruct, "y", MouseGetPos(1))
$hWnd = _WinAPI_WindowFromPoint($g_tStruct)

Both functions are returning handles as they should, but not everytime the handle to the GUI.
For example if you have a GUI with a Progressbar inside and you click on the progressbar, those functions return the Handle to the Progressbar and not the GUI containing it.
What I want to get is the handle to the GUI, but I couldn't find a way of getting from Controlhandle to GUi Handle.

In my case I have a couple of child GUIs and want to know which one was clicked on ..

Do you know a way to achieve this?

Thanks for your help! :)

Edited by Leo1906

Share this post

Link to post
Share on other sites

Okay .. while writing this post I got a new idea ..
You can retrieve the handle by simply calling WinGetHandle(""), which returns the handle of the currently active window. If one of my child GUIs has been clicked on it should have get active and for this the correct handle would be returned ..

So far it seems to work with this solution. Sorry for making a post and then answering the question a few minutes later .. o:)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this