As the title says, I am trying to find the hwnd for the dropdown associated with a combobox control that I've created in a AHK GUI. I've tried several approaches, including DLL calls from various threads on the forum (e.g. viewtopic.php?t=49374) that try to find the parent of a given control, but with no luck. I am about to just resort to using mouse coordinates, but I figured I would see if anyone more knowledgeable might have some insights.
To give a little context to what I'm trying to do: I have a script where an AHK GUI window shows up when I put the mouse in a particular area, stays visible while I do things inside it, and then disappears when I move the mouse away. I have been using MouseGetPos, x, y, id and comparing id to the hwnd of the GUI that I created. It was working great until I added a combobox control, and then when I dropdown and try to select an item, the window disappears. I eventually figured out that the issue is that the combobox dropdown is actually a separate window from the main GUI. But I cannot figure out how to get the hwnd of this window so I know when the mouse is over it. I tried using MouseGetPos, x, y, id, pid and comparing the pid of the main GUI and the dropdown, but even those seem to be different (which I wouldn't have expected).
Here's a minimal example:
Code: Select all
Gui, New, AlwaysOnTop hwndMainGUI, test
Gui, Add, ComboBox, x5 y20 w100 r4 hwndUserComboCtrl, A|B|C|D
Gui, Add, Button, x10 y50 w100 h30, Button1
Gui, Show, x100 y100 h200 w200
SetTimer, ShowWindowUnderMouse, 200
return
ShowWindowUnderMouse:
MouseGetPos, Mxpos, Mypos, Mhwnd
if (Mhwnd = MainGUI)
overWin := true
else
overWin := false
ToolTip, main win hwnd: %MainGUI% `n hwnd under mouse: %Mhwnd% `n overWin? %overWin%
return
GuiClose:
ExitApp
return
After struggling with this for hours, I realize the easiest thing might be to just see if the x,y returned by MouseGetPos is within the window boundaries, but I'm still curious if there's a way to do this. Thanks so much for any advice.