this works fine:
Code: Select all
GuiControlGet, HWND_Number1, HWND, Button1
MsgBox % HWND_Number1,
Code: Select all
Get_HWND_Of_Control(Button1)
Get_HWND_Of_Control(vControl){
GuiControlGet, HWND_Number1 , HWND, %vControl%
MsgBox % HWND_Number1
}
Code: Select all
GuiControlGet, HWND_Number1, HWND, Button1
MsgBox % HWND_Number1,
Code: Select all
Get_HWND_Of_Control(Button1)
Get_HWND_Of_Control(vControl){
GuiControlGet, HWND_Number1 , HWND, %vControl%
MsgBox % HWND_Number1
}
Code: Select all
Get_HWND_Of_Control("Button1")
WantToKnow wrote: ↑09 Dec 2021, 07:59Hello Mike,
that is exactly what I have done before. I thought I was making a syntax error, but your code looks exactly like mine.
Unfortunately the code does not show me the wanted HWND number this way. Even if the post here says otherwise.
I have tried all the possibilities before.
Code: Select all
Gui, Add, Button,, This test really works.
Gui, Show, x200 y200
SetTimer, Tip, 200
Get_HWND_Of_Control("Button1")
Tip:
MouseGetPos,,,, fc
GuiControlGet, hWnd, HWND, %fc%
ToolTip, % hWnd ? fc " = " hWnd : ""
Return
Get_HWND_Of_Control(vControl){
GuiControlGet, HWND_Number1, HWND, %vControl%
MsgBox, 64, HWND for %vControl%, %HWND_Number1%
}
Code: Select all
Gui, New
Gui, Add, Button,, This test really works.
Gui, Show, x200 y200
GuiControlGet, HWND_Number1, HWND, Button1
MsgBox, % HWND_Number1
Return
F11:: Get_HWND_Of_Control("Button1")
Get_HWND_Of_Control(vControl){
GuiControlGet, HWND_Number1, HWND, %vControl%
MsgBox % HWND_Number1
}
Code: Select all
Gui, New, +Hwndgui1
Gui, Add, Button,, This test really works.
Gui, Show, x200 y200
SetTimer, Tip, 200
Get_HWND_Of_Control(gui1, "Button1")
Tip:
Gui, %gui1%:Default
MouseGetPos,,,, fc
GuiControlGet, hWnd, HWND, %fc%
ToolTip, % hWnd ? fc " = " hWnd : ""
Return
Get_HWND_Of_Control(guiHWND, vControl){
Gui, %guiHWND%:Default
GuiControlGet, HWND_Number1, HWND, %vControl%
MsgBox, 64, HWND for %vControl%, %HWND_Number1%
}
If you have a GUI name as you do, then you can use that instead of the GUI HWND.Although the new window is set as the default for the current thread, non-GUI threads still default to GUI number 1. If the GUI has no name and is not the default GUI, it must be identified by its HWND.
Code: Select all
Gui, MainGui:New
Gui, Add, Button,, This test really works.
Gui, Show, x200 y200
SetTimer, Tip, 200
Get_HWND_Of_Control("MainGui", "Button1")
Tip:
Gui, MainGui:Default
MouseGetPos,,,, fc
GuiControlGet, hWnd, HWND, %fc%
ToolTip, % hWnd ? fc " = " hWnd : ""
Return
Get_HWND_Of_Control(gui, vControl){
Gui, %gui%:Default
GuiControlGet, HWND_Number1, HWND, %vControl%
MsgBox, 64, HWND for %vControl%, %HWND_Number1%
}