speedi Posted November 9, 2009 Posted November 9, 2009 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
omikron48 Posted November 9, 2009 Posted November 9, 2009 (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 November 9, 2009 by omikron48
lilx Posted November 9, 2009 Posted November 9, 2009 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.
AndyG Posted November 10, 2009 Posted November 10, 2009 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
speedi Posted November 10, 2009 Author Posted November 10, 2009 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...
Yashied Posted November 10, 2009 Posted November 10, 2009 Opt("WinWaitDelay", 0) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
omikron48 Posted November 10, 2009 Posted November 10, 2009 (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 November 10, 2009 by omikron48
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now