#NoTrayIcon
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
;~ #include <WinAPISysWin.au3>
Local $Search = False
Global $g_tStruct = DllStructCreate($tagPOINT)
$Form1 = GUICreate("Form1", 436, 131, -1, -1, -1, $WS_EX_TOPMOST)
$Label1 = GUICtrlCreateLabel("标题", 48, 16, 36, 17)
$Label2 = GUICtrlCreateLabel("句柄", 48, 48, 36, 17)
$Label3 = GUICtrlCreateLabel("类名", 48, 80, 36, 17)
$Input1 = GUICtrlCreateInput("", 80, 16, 337, 21)
$Input2 = GUICtrlCreateInput("", 80, 48, 337, 21)
$Input3 = GUICtrlCreateInput("", 80, 80, 337, 21)
$ico = GUICtrlCreateIcon(@SystemDir & '\shell32.dll', -23, 10, 48, 30, 30)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_LBUTTONUP, "_check")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ico
$Search = True
DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $Form1)
EndSwitch
WEnd
Func Position()
DllStructSetData($g_tStruct, "x", MouseGetPos(0))
DllStructSetData($g_tStruct, "y", MouseGetPos(1))
EndFunc ;==>Position
Func _check()
$Search = False
DllCall("user32.dll", "int", "ReleaseCapture")
Local $winHD = '',$hParent
Position()
$winHD = _WinAPI_WindowFromPoint($g_tStruct)
While 1
$hParent = _WinAPI_GetParent($winHD)
If $hParent = 0 Then ExitLoop
$winHD = $hParent
WEnd
;$winHD=_WinAPI_GetParent ( $winHD1 )
GUICtrlSetData($Input1, _WinAPI_GetWindowText($winHD))
GUICtrlSetData($Input2, $winHD)
;$pClassName = DllStructCreate("char[256]")
;DllCall("user32.dll", "int", "GetClassName", "hwnd", $winHD, "ptr", DllStructGetPtr($pClassName), "int", 255)
GUICtrlSetData($Input3, _WinAPI_GetClassName($winHD))
EndFunc ;==>_check
|