#include<winapi.au3>
$Parent = _FindWindow("#32770", "Microsoft Internet Explorer")
If Not($Parent) Then Exit MsgBox(16,"错误","没找到对话框")
MsgBox(64,"找到文本",WinGetTitle(_WinAPI_GetWindow(_FindWindowEx("Static", "", $Parent),2)))
Func _FindWindow($sClass, $sTitle = "")
Local $tClass = DllStructCreate("wchar[" & StringLen($sClass) + 1 & "]")
DllStructSetData($tClass, 1, $sClass)
Local $tTitle = DllStructCreate("wchar[" & StringLen($sTitle) + 1 & "]")
DllStructSetData($tTitle, 1, $sTitle)
Local $hWnd = DllCall("user32.dll", "hwnd", "FindWindowW", "ptr", DllStructGetPtr($tClass), "ptr", DllStructGetPtr($sTitle))
If Not $hWnd[0] Then Return SetError(1, 0, 0)
Return $hWnd[0]
EndFunc ;==>_FindWindow
Func _FindWindowEx($lpszClass, $lpszWindow = "", $hWndParent = 0, $hWndChildAfter = 0)
Local $tClass = DllStructCreate("wchar[" & StringLen($lpszClass) + 1 & "]")
DllStructSetData($tClass, 1, $lpszClass)
Local $tTitle = DllStructCreate("wchar[" & StringLen($lpszWindow) + 1 & "]")
DllStructSetData($tTitle, 1, $lpszWindow)
Local $hWnd = DllCall("user32.dll", "hwnd", "FindWindowExW", "hwnd", $hWndParent, "hwnd", $hWndChildAfter, "ptr", DllStructGetPtr($tClass), "ptr", DllStructGetPtr($tTitle))
If Not $hWnd[0] Then Return SetError(1, 0, 0)
Return $hWnd[0]
EndFunc ;==>_FindWindowEx
|