#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 587, 395, 192, 114)
$ListView1 = GUICtrlCreateListView("窗口状态|窗口标题", 48, 32, 497, 329,$LVS_NOLABELWRAP)
GUISetState(@SW_SHOW)
win()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func win()
$var = WinList()
For $i = 1 to $var[0][0]
; 仅显示带标题的可见窗口
If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
if $var[$i][1] = $Form1 or $var[$i][0] = "Program Manager" then
GuiCtrlCreateListViewItem("未关闭" & "|" & $var[$i][0],$ListView1)
else
WinKill($var[$i][1])
GuiCtrlCreateListViewItem("已关闭" & "|" & $var[$i][0],$ListView1)
endif
EndIf
Next
EndFunc
Func IsVisible($handle)
If BitAnd( WinGetState($handle), 2 ) Then
Return 1
Else
Return 0
EndIf
EndFunc
|