函数参考


_WinAPI_WindowFromPoint

检索包含指定点的窗口句柄

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

参数

$tPoint 定义检查点的 $tagPOINT 结构

返回值

成功: 返回包含指定点的窗口句柄
失败: 返回 0

注意/说明

 函数不检索隐藏或禁用窗口句柄, 即使是在窗口点.

相关

$tagPOINT

详情参考

在MSDN中搜索


示例/演示


#include <WinAPI.au3>

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

Global $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($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($tStruct, "x", MouseGetPos(0))
    DllStructSetData($tStruct, "y", MouseGetPos(1))
EndFunc   ;==>Position

Func Close()
    Exit
EndFunc   ;==>Close