Leo1906 Posted September 12, 2016 Share Posted September 12, 2016 (edited) 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 September 12, 2016 by Leo1906 Link to comment Share on other sites More sharing options...
Leo1906 Posted September 12, 2016 Author Share Posted September 12, 2016 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 .. Link to comment Share on other sites More sharing options...
InunoTaishou Posted September 12, 2016 Share Posted September 12, 2016 #include <WinAPI.au3> Global $hGui = GUICreate("") Global $lblLabel = GUICtrlCreateLabel("", 0, 0) ConsoleWrite($hGui & @LF) ConsoleWrite(_WinAPI_GetParent(GUICtrlGetHandle($lbl)) & @LF) Leo1906 1 Link to comment Share on other sites More sharing options...
Leo1906 Posted September 12, 2016 Author Share Posted September 12, 2016 Just now, InunoTaishou said: #include <WinAPI.au3> Global $hGui = GUICreate("") Global $lblLabel = GUICtrlCreateLabel("", 0, 0) ConsoleWrite($hGui & @LF) ConsoleWrite(_WinAPI_GetParent(GUICtrlGetHandle($lbl)) & @LF) Okay, this is what I was looking for the last hours Thanks a lot Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now