#include <WindowsConstants.au3>
#include <Process.au3>
#include <WinAPI.au3>
#Include <WinAPIEx.au3> ;WinAPIEx调用
#include <Array.au3>
HotKeySet("{ESC}", "Close") ; Set ESC as a hotkey to exit the script.
Global $tStruct = DllStructCreate($tagPOINT), $MouseX, $MouseY
Example()
Func Example()
Local $classN = '[CLASS:'
While 1
If MouseGetPos(0) <> $MouseX Or MouseGetPos(1) <> $MouseY Then
Local $x0 = Null, $x0c = Null, $x0t = Null, $x0d = Null, $x0n = Null, $x0p = Null
Local $x1 = Null, $x1c = Null, $x1t = Null, $x1d = Null, $x1n = Null, $x1p = Null
Local $x2 = Null, $x2c = Null, $x2t = Null, $x2d = Null, $x2n = Null, $x2p = Null, $x2a = Null, $x2list = Null
Position() ; Update the X and Y elements with the X and Y co-ordinates of the mouse.
$x0 = _WinAPI_GetForegroundWindow() ;返回激活前台窗口句柄
$x0d = WinGetProcess($x0)
$x0n = _ProcessGetName($x0d)
$x0p = WinGetPos($x0)
$x0c = $classN & _WinAPI_GetClassName($x0) & ']'
$x0t = _WinAPI_GetWindowText($x0)
$x1 = _WinAPI_WindowFromPoint($tStruct) ; 检索包含指定XY坐标的窗口句柄
$x1d = WinGetProcess($x1)
$x1n = _ProcessGetName($x1d)
$x1p = WinGetPos($x1)
$x1c = $classN & _WinAPI_GetClassName($x1) & ']' ;返回ClassName
$x1t = _WinAPI_GetWindowText($x1)
$x2 = _WinAPI_GetAncestor($x1, $GA_ROOT) ; 检索父窗口活链接的根窗口
If @error Then
If IsArray($x0p) And IsArray($x1p) Then
ToolTip('激活前台窗口>> 进程名=' & $x0n & ' |||PID=' & $x0d & ' |||句柄=' & $x0 & ' |||类名=' & $x0c & ' |||窗名=' & $x0t & ' |||尺寸=x:' & $x0p[0] & ' y:' & $x0p[1] & ' w:' & $x0p[2] & ' h:' & $x0p[3] & @CRLF & _
@CRLF & '鼠标坐标窗口>> 进程名=' & $x1n & ' |||PID=' & $x1d & ' |||句柄=' & $x1 & ' |||类名=' & $x1c & ' |||窗名=' & $x1t & ' |||尺寸=x:' & $x1p[0] & ' y:' & $x1p[1] & ' w:' & $x1p[2] & ' h:' & $x1p[3], _
200, 50)
EndIf
Else
$x2d = WinGetProcess($x2)
$x2n = _ProcessGetName($x2d)
$x2p = WinGetPos($x2)
$x2c = $classN & _WinAPI_GetClassName($x2) & ']'
$x2t = _WinAPI_GetWindowText($x2)
$x2a = _WinAPI_EnumChildWindows($x2)
If Not @error Then
If $x2a[0][0] > 0 Then
For $i = 1 To $x2a[0][0]
Local $x = ControlGetPos($x2a[$i][0], "", '')
;~ If $x2a[$i][1] = 'Internet Explorer_Server' Then
;~ ControlHide($x2a[$i][0], '', '')
;~ Sleep(1000)
;~ _WinAPI_PostMessage($x2a[$i][0], 0x0010, 0, 0)
;~ EndIf
If $x2list Then
If $x2a[$i][0] = $x1 Then
$x2list &= @CRLF& $x2a[$i][0] &' || [CLASS:'& $x2a[$i][1] &'] ||x:'& $x[0] &' y:'& $x[1] &' w:'& $x[2] &' h:'& $x[3] & ' <<-- 鼠标坐标子窗 '&$x1
Else
$x2list &= @CRLF& $x2a[$i][0] &' || [CLASS:'& $x2a[$i][1] &'] ||x:'& $x[0] &' y:'& $x[1] &' w:'& $x[2] &' h:'& $x[3]
EndIf
Else
If $x2a[$i][0] = $x1 Then
$x2list = '=========枚举[句柄: '&$x2&']父窗下的子窗=========' &@CRLF& $x2a[$i][0] &' || [CLASS:'& $x2a[$i][1] &'] ||x:'& $x[0] &' y:'& $x[1] &' w:'& $x[2] &' h:'& $x[3] & ' <<-- 鼠标坐标子窗 '&$x1
Else
$x2list = '=========枚举[句柄: '&$x2&']父窗下的子窗=========' &@CRLF& $x2a[$i][0] &' || [CLASS:'& $x2a[$i][1] &'] ||x:'& $x[0] &' y:'& $x[1] &' w:'& $x[2] &' h:'& $x[3]
EndIf
EndIf
Next
EndIf
EndIf
If IsArray($x0p) And IsArray($x1p) And IsArray($x2p) Then
ToolTip('激活前台窗口>> 进程名=' & $x0n & ' |||PID=' & $x0d & ' |||句柄=' & $x0 & ' |||类名=' & $x0c & ' |||窗名=' & $x0t & ' |||尺寸=x:' & $x0p[0] & ' y:' & $x0p[1] & ' w:' & $x0p[2] & ' h:' & $x0p[3] & @CRLF & _
@CRLF & '鼠标坐标父窗>> 进程名=' & $x2n & ' |||PID=' & $x2d & ' |||句柄=' & $x2 & ' |||类名=' & $x2c & ' |||窗名=' & $x2t & ' |||尺寸=x:' & $x2p[0] & ' y:' & $x2p[1] & ' w:' & $x2p[2] & ' h:' & $x2p[3] & _
@CRLF & '鼠标坐标窗口>> 进程名=' & $x1n & ' |||PID=' & $x1d & ' |||句柄=' & $x1 & ' |||类名=' & $x1c & ' |||窗名=' & $x1t & ' |||尺寸=x:' & $x1p[0] & ' y:' & $x1p[1] & ' w:' & $x1p[2] & ' h:' & $x1p[3] & @CRLF & $x2list, _
200, 50)
EndIf
EndIf
EndIf
Sleep(3000)
WEnd
EndFunc ;==>Example
;
Func Position()
$MouseX = MouseGetPos(0)
$MouseY = MouseGetPos(1)
DllStructSetData($tStruct, "x", $MouseX)
DllStructSetData($tStruct, "y", $MouseY)
EndFunc ;==>Position
Func Close()
Exit
EndFunc ;==>Close
|