Jump to content

Close all instances of...except for..


Recommended Posts

Hi All

As the title asks.. Is there a quick, clean way of closing several of the same windows(Explorer.exe), but leaving the desktop and startbar intact?

I imagine I need to list all the windows with process of explorer.exe and then cycle through them, not closing the desktop version.

I don't want to write a 20 line version if there is a simple 4 or 5 line version that 1 of you already use.

Thanks in advance

Link to comment
Share on other sites

Just to show I am trying, I have put this together

$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], 2)
    If $var[$i][0] = "Program Manager" Then ExitLoop
    WinClose($var[$i][0])
  EndIf
Next

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

But I'm hoping there is a cleaner version

Edited by happy2help
Link to comment
Share on other sites

For browse/explore windows, this will work:

#include <Array.au3>
$aExplorerWins=WinList("[REGEXPCLASS:(Explore|Cabinet)]")
_ArrayDisplay($aExplorerWins,"Explorer Windows")

*sorry, I didnt actually close the windows - but you can do that easily with a loop

Edited by Ascend4nt
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...