#include <WinAPI.au3>
$iYes = 0
$iNo = 0
$iAll = 0
$aList = WinList()
If $aList[0][0] Then
For $i = 1 To $aList[0][0]
$sClass = _WinAPI_GetClassName($aList[$i][1])
If $sClass <> 'Progman' And $sClass <> 'Shell_TrayWnd' Then
If $aList[$i][0] Then
If BitAND(WinGetState($aList[$i][1]), 2) Then
If Not WinActive($aList[$i][1]) Then
$iAll += 1
MsgBox(64, 'Info', $aList[$i][0])
;If WinClose($aList[$i][1]) Then
; $iYes += 1
;Else
; $iNo += 1
;EndIf
;или
;WinSetState($aList[$i][1], @SW_MINIMIZE)
EndIf
EndIf
EndIf
EndIf
Next
EndIf
MsgBox(64, 'Info', 'Закрыли: ' & $iYes & ' окон' & @LF & 'Не смогли закрыть: ' & $iNo & ' окон' & @LF _
& 'Из: ' & $iAll & ' окон')