Sign in to follow this  
Followers 0
happy2help

Close all instances of...except for..

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks,

I just knocked this up and it seams to work

$var = WinList("[REGEXPCLASS:(Explore|Cabinet)]") 
For $i = 1 to $var[0][0]
  WinClose($var[$i][0])
Next

I can just repeat with different Winlist expressions as necessary.

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  
Followers 0