Sign in to follow this  
Followers 0
speedi

why so slowwww?

7 posts in this topic

This script to close all open windows except 2 is so very slow to finish. I am trying it with just 3 applications running...

Please help! Frustrated.

THE SCRIPT:

; close all open windows with 2 exceptions

$var = WinList() ; create array with allopen windows

For $i = 1 to $var[0][0] ; close all open windows

winactivate($var[$i][0] )

If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then

if $var[$i][0] <> "C:\Documents and Settings\Jim Mihalski\My Documents\data\daily setup.au3 - SciTE" AND $var[$i][0] <> "Program Manager" Then

winclose($var[$i][0] )

WinWaitClose($var[$i][0] )

endif

EndIf

Next

exit

; Functions for Script

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



#2 ·  Posted (edited)

Maybe you should try not waiting for the window to close before you handle the next one?

Or maybe WinList also lists child windows and their parents all the same, not sure since I haven't used WinList yet. If that's the case, I'm not exactly sure if other programs respond when you try closing the parent window while its child is still active.

Edited by omikron48

Share this post


Link to post
Share on other sites

i have used winlist before,

and if am i correct you still are closing a bunch of windows no matter that you filterd some out.

i think the for you to do for a little debugging putting a _ArrayDisplay into it.

so you can see how much windows it is handeling. and wich one it will be closing.

i am not a expert. but while working with winlist it helped me alot.

Share this post


Link to post
Share on other sites

Hi,

if you want to close all opened windows except of those two, why do you activate them first?

#include <Array.au3>
#include <File.au3>
$WinList = WinList()
Dim $WinListVis[1] = [0]
For $i = 1 To $WinList[0][0]
 If BitAND(WinGetState($WinList[$i][1]), 2) Then _ArrayAdd($WinListVis, WinGetTitle($WinList[$i][1]))
Next
$WinListVis[0] = UBound($WinListVis) - 1
_ArrayDisplay($WinListVis) ;shows all open windows

;close all except your choice
For $i = 1 To $WinListVis[0]
 If $WinListVis[$i] = "C:\Documents and Settings\Jim Mihalski\My Documents\data\daily setup.au3 - SciTE" Or $WinListVis[$i] = "Program Manager" Then ContinueLoop
 WinClose(WinGetTitle($WinList[$i][1]))
Next

Share this post


Link to post
Share on other sites

Thanks for all the help.

I have modified the script from an example on the forum...

This is it:

******************************

$var = WinList ()

For $i = 1 to $var[0][0]

If BitAnd (WinGetState ($var[$i][1]), 2) And $var[$i][0] <> "" And $var[$i][0] <> "Program Manager" Then WinClose ($var[$i][1], "")

Next

*******************************

I still don't know why the old script was slow (I mean very slow).. But the script above is lighting fast by comparison... Maybe it was the isvisible function...

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I doubt it was the IsVisible. I'm betting it was the WinWaitClose. It slows it down when the app is slow in closing.

Edited by omikron48

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