ClayR Posted July 1, 2009 Share Posted July 1, 2009 Ok - I have looked around on the forum, but havent really seen an answer to this. I am looking for a command to close all stray windows that are open when completing my script. About 10% of the time, a window is left open (that doesnt have a predictable header or name associated with it), and the script won't run the next time with this window open. Any thoughts? I am sure this is super simple, but I am just starting out! Any thoughts would be helpful. Link to comment Share on other sites More sharing options...
Yashied Posted July 1, 2009 Share Posted July 1, 2009 Ok - I have looked around on the forum, but havent really seen an answer to this.I am looking for a command to close all stray windows that are open when completing my script. About 10% of the time, a window is left open (that doesnt have a predictable header or name associated with it), and the script won't run the next time with this window open.Any thoughts? I am sure this is super simple, but I am just starting out! Any thoughts would be helpful.GUIDelete()? 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... Link to comment Share on other sites More sharing options...
Mat Posted July 1, 2009 Share Posted July 1, 2009 GUIDelete()? I think he was looking for a way to close non-autoit windows... If so, here is the solution $var = WinList () For $i = 1 to $var[0][0] If BitAnd (WinGetState ($var[$i][1]), 2) And $var[$i][0] <> "" Then WinClose ($var[$i][1], "") Next adapted to purpose from the autoit helpfile example for winlist. MDiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
ClayR Posted July 1, 2009 Author Share Posted July 1, 2009 Thank you for the quick reply! You are exactly correct, I am wanting to close Explorer windows that remain. I have implemented the code (thank you) but it seems to want to restart (the shutdown dialog box pops up at the end of the script). Is there a way to avoid this? Thx! I think he was looking for a way to close non-autoit windows... If so, here is the solution $var = WinList () For $i = 1 to $var[0][0] If BitAnd (WinGetState ($var[$i][1]), 2) And $var[$i][0] <> "" Then WinClose ($var[$i][1], "") Next adapted to purpose from the autoit helpfile example for winlist. MDiesel Link to comment Share on other sites More sharing options...
Mat Posted July 1, 2009 Share Posted July 1, 2009 $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 stab in the dark. I'm picking up a "Program Manager" window, without any open, so maybe its a background process, that is set to prompt for sutdown on close? I haven't tried it yet, I have a lot of important and unsaved windows open at the mo. MDiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 1, 2009 Share Posted July 1, 2009 Thank you for the quick reply! You are exactly correct, I am wanting to close Explorer windows that remain. I have implemented the code (thank you) but it seems to want to restart (the shutdown dialog box pops up at the end of the script). Is there a way to avoid this?Thx!Probably Program Manager is in the $var array, so remove it or don't execute WinClose on it. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
ClayR Posted July 1, 2009 Author Share Posted July 1, 2009 Ok- So I have run this a bit more, and I think I figured out what is going on. At the end of my process, I shut down a website. When I do this, about 10% I get a dialog box with a header of "Windows Internet Explorer" saying: "The webpage you are viewing is trying to close the window. Do you want to close the window?"I can't get rid of this window, and it pops up in random places and times. I have tried the code you suggested, also WinClose("Windows Internet Explorer") to no avail.Probably Program Manager is in the $var array, so remove it or don't execute WinClose on it. Link to comment Share on other sites More sharing options...
Mat Posted July 1, 2009 Share Posted July 1, 2009 Have you tried replacing winclose with WinKill??The difference between this function and WinClose is that WinKill will forcibly terminate the window if it doesn't close quickly enough. Consequently, a user might not have time to respond to dialogs prompting the user to save data. Although WinKill can work on both minimized and hidden windows, some windows (notably explorer windows) can only be terminated using WinClose.MDesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
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