oMBRa Posted October 30, 2008 Posted October 30, 2008 I have an handle of a control, and with it I should get the handle of the window owner, but how to do it?
oMBRa Posted October 31, 2008 Author Posted October 31, 2008 this is my code: #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet('{F2}', 'Esc') Global $tPOINT = DllStructCreate("int X;int Y") While 1 Sleep(10) DllStructSetData($tPOINT, 'X', _WinAPI_GetMousePosX()) DllStructSetData($tPOINT, 'Y', _WinAPI_GetMousePosY()) $hWnd = _WinAPI_WindowFromPoint($tPOINT) ToolTip('' & _WinAPI_GetWindowText($hWnd), 0, 0) WEnd Func Esc() Exit EndFunc ;==>Esc with that code I get the text of the control, but I need the name of the window that own the control
ProgAndy Posted October 31, 2008 Posted October 31, 2008 Well, you have to use _WinAPI_GetParetn, as evilertoaster said #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet('{F2}', 'Esc') Global $tPOINT = DllStructCreate("int X;int Y") While 1 Sleep(10) $tPOINT= _WinAPI_GetMousePos() $hWnd = _WinAPI_WindowFromPoint($tPOINT) ; Get the "real" parent window ( also from child of child :) ) $hWnd2 = $hWnd Do $hWnd = $hWnd2 $hWnd2 = _WinAPI_GetParent($hWnd) Until $hWnd2=0 $title = WinGetTitle($hWnd) ; Show Class for Window without Title If $title = "" Then $title = "[CLASS:"&_WinAPI_GetClassName($hWnd)&"]" ToolTip($title, 0, 0) WEnd Func Esc() Exit EndFunc ;==>Esc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
LarryDalooza Posted October 31, 2008 Posted October 31, 2008 Because a Parent can have a Parent... I use...user32.dll - GetAncestor() with $GA_ROOT=2Retrieves the root window by walking the chain of parent windows.Lar. AutoIt has helped make me wealthy
ProgAndy Posted October 31, 2008 Posted October 31, 2008 (edited) Hey. this is better... didn't know that it exists #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet('{F2}', 'Esc') Global $tPOINT = DllStructCreate("int X;int Y") While 1 Sleep(10) $tPOINT= _WinAPI_GetMousePos() $hWnd = _WinAPI_WindowFromPoint($tPOINT) ; Get the "real" parent window ( also from child of child smile.gif ) $hWnd2 = _WinAPI_GetAncestor($hWnd,2) If Not($hWnd2 = 0) Then $HWnd = $hWnd2 $title = WinGetTitle($hWnd) ; Show Class for Window without Title If $title = "" Then $title = "[CLASS:"&_WinAPI_GetClassName($hWnd)&"]" ToolTip($title, 0, 0) WEnd Func Esc() Exit EndFunc ;==>Esc Edited October 31, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
oMBRa Posted October 31, 2008 Author Posted October 31, 2008 yes u are right: #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet('{F2}', 'Esc') Global $tPOINT = DllStructCreate("int X;int Y") While 1 Sleep(10) $tPOINT = _WinAPI_GetMousePos() $hWnd = _WinAPI_WindowFromPoint($tPOINT) ToolTip('' & _WinAPI_GetWindowText(_WinAPI_GetAncestor($hWnd, 2)), 0, 0) WEnd Func Esc() Exit EndFunc ;==>Esc
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