Function Reference


_WinAPI_WindowFromPoint

Retrieves the handle of the window that contains the specified point

#include <WinAPI.au3>
_WinAPI_WindowFromPoint ( ByRef $tPoint )

Parameters

$tPoint $tagPOINT structure that defines the point to be checked

Return Value

Success: The handle of the window that contains the point
Failure: 0

Remarks

The WindowFromPoint function does not retrieve the handle of a hidden or disabled window, even if the point is
within the window.

Related

$tagPOINT

See Also

Search WindowFromPoint in MSDN Library.

Example

#include <WinAPI.au3>

HotKeySet("{ESC}", "Close") ; Set ESC as a hotkey to exit the script.

Global $g_tStruct = DllStructCreate($tagPOINT) ; Create a structure that defines the point to be checked.

Example()

Func Example()
    Local $hWnd

    While 1
        ToolTip("")
        Position() ; Update the X and Y elements with the X and Y co-ordinates of the mouse.
        $hWnd = _WinAPI_WindowFromPoint($g_tStruct) ; Retrieve the window handle.
        ToolTip($hWnd) ; Set the tooltip with the handle under the mouse pointer.
        Sleep(100)
    WEnd
EndFunc   ;==>Example

Func Position()
    DllStructSetData($g_tStruct, "x", MouseGetPos(0))
    DllStructSetData($g_tStruct, "y", MouseGetPos(1))
EndFunc   ;==>Position

Func Close()
    Exit
EndFunc   ;==>Close