Jump to content
Sign in to follow this  
Oldschool

Closing all active windows

Recommended Posts

Oldschool

I wrote this, but it tries to kill everything...including the "program manager"

I just want to close windows that are visible...

Any ideas?

WinSetState($MainApp, "", @SW_MINIMIZE) 
$win = WinList()
For $wl = 0 To $win[0][0]
   If WinExists($win[$wl][0]) And IsVisible($win[$wl][0]) = 1 Then
          WinClose($win[$wl][0])
   EndIf
Next

Func IsVisible($handle)
      If BitAnd( WinGetState($handle), 2 ) Then 
        Return 1
      Else
        Return 0
      EndIf
EndFunc
Edited by Oldschool

Share this post


Link to post
Share on other sites
DjDeep00

Try this out...

$var = WinList()

For $i = 1 to $var[0][0]
 ; Only display visble windows that have a title
  If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
   ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
    If $var[$i][0]<>"Program Manager" then WinClose($var[$i][0])
  EndIf
Next

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc

Share this post


Link to post
Share on other sites
weaponx

What is considered visible? Does that include minimized?

Share this post


Link to post
Share on other sites
Blue_Drache

No, minimized sets its own bit.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×