枚举所有顶层窗口
#Include <WinAPI.au3>
_WinAPI_EnumWindowsTop()
返回数组的格式如下: | |
[0][0] - 数组的行数 (n) | |
[1][0] - 窗口句柄 | |
[1][1] - 窗口的类名称 | |
[n][0] - 窗口句柄 | |
[n][1] - 窗口的类名称 |
#include <WinAPI.au3>
_Main()
Func _Main()
Local $aWindows, $i, $text
$aWindows = _WinAPI_EnumWindowsTop()
For $i = 1 To $aWindows[0][0]
$text = "Window Handle: " & $aWindows[$i][0] & @LF
$text &= "Window Class: " & $aWindows[$i][1] & @LF
$text &= "Window Title: " & WinGetTitle($aWindows[$i][0]) & @LF
$text &= "Window Text: " & WinGetText($aWindows[$i][0]) & @LF
$text &= "Window Process: " & WinGetProcess($aWindows[$i][0])
MsgBox(0, "Item " & $i & " of " & $aWindows[0][0], $text)
Next
EndFunc ;==>_Main