Dirk98 Posted September 22, 2007 Posted September 22, 2007 Guys, how to script "close all open instances of Explorer and IE browser" only but don't touch other application windows? Thanks.
Moderators SmOke_N Posted September 22, 2007 Moderators Posted September 22, 2007 Guys, how to script "close all open instances of Explorer and IE browser" only but don't touch other application windows?Thanks.Don't think you really want to close explorer do you?Anyway, for ie... You could just close the process and make it simple.pseudo code (not tested):Global $aPL = ProcessList("iexplore.exe") For $iCC = 1 To $aPL[0][0] ProcessClose($aPL[$iCC][1]) Next Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Nahuel Posted September 22, 2007 Posted September 22, 2007 Maybe using ProcessClose("iexplore.exe"). Alternate method: $WinList=WinList("- Internet Explorer") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) Next
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 Thanks, guys, for the IE tip. I also meant to close all open file folders. How to do that? Thanks.
Nahuel Posted September 22, 2007 Posted September 22, 2007 Hum, like this? Opt("WinTitleMatchMode",4) $WinList=WinList("classname=CabinetWClass") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) Next
Tiger Posted September 22, 2007 Posted September 22, 2007 Use this for close the file folders Global $aPL = ProcessList("explorer.exe") For $iCC = 1 To $aPL[0][0] ProcessClose($aPL[$iCC][1]) Next My UDFs:- _RegEnumKey
Nahuel Posted September 22, 2007 Posted September 22, 2007 Use this for close the file foldersGlobal $aPL = ProcessList("explorer.exe") For $iCC = 1 To $aPL[0][0] ProcessClose($aPL[$iCC][1]) NextWon't this terminate explorer causing the desktop to go blank?
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 (edited) Use this for close the file foldersGlobal $aPL = ProcessList("explorer.exe") For $iCC = 1 To $aPL[0][0] ProcessClose($aPL[$iCC][1]) NextWon't this terminate explorer causing the desktop to go blank? Guys, can anyone try out this code please? No, pls don't do that, just messing.Seriously, will that code close explorer.exe process indeed? No good. Edited September 22, 2007 by Dirk98
Nahuel Posted September 22, 2007 Posted September 22, 2007 (edited) haha, yeah. I tried it and it did that. As expected. If you want to close the Windows Explorer windows (Like, my documents, my music, whatever) this works: Opt("WinTitleMatchMode",4) $WinList=WinList("classname=CabinetWClass") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) Next For Internet Explorer windows: Opt("WinTitleMatchMode",2) $WinList=WinList("- Internet Explorer") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) Next And so on.. Use the AutoIt Window Info Tool. It's very useful for this kind of things. -edit- typo. Edited September 22, 2007 by Nahuel
Tiger Posted September 22, 2007 Posted September 22, 2007 Guys, can anyone try out this code please? No, pls don't do that, just messing.Seriously, will that code close explorer.exe process indeed? No good.I have test it. the script close the explorer My UDFs:- _RegEnumKey
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 (edited) haha, yeah. I tried it and it did that. As expected.If you want to close the Windows Explorer windows (Like, my documents, my music, whatever) this works:Opt("WinTitleMatchMode",4) $WinList=WinList("classname=CabinetWClass") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) NextFor Internet Explorer windows:Opt("WinTitleMatchMode",2) $WinList=WinList("- Internet Explorer") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) NextAnd so on.. Use the AutoIt Window Info Tool. It's very useful for this kind of things.-edit- typo.Nahuel, they look very nice, but could you please check them again? The both don't work, but they look like what I asked for in the beginning. Thank you. Edited September 22, 2007 by Dirk98
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 (edited) Don't think you really want to close explorer do you?Anyway, for ie... You could just close the process and make it simple.pseudo code (not tested):Global $aPL = ProcessList("iexplore.exe") For $iCC = 1 To $aPL[0][0] ProcessClose($aPL[$iCC][1]) NextSmokeOn: your script works very well.I need a similar one for all open file folders. The one that Nahuel suggested first kicks out some of my programs in the TrayBar to some reason. Then he suggested another one that unfortunately doesn't close the folder where the script is run from. Thanks, guys. Edited September 22, 2007 by Dirk98
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 Opt("WinTitleMatchMode",4) $WinList=WinList("classname=CabinetWClass") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) Next Nahuel, your code above closes all open windows file folders except the one where the script is run from. Can you please look into it.
Nahuel Posted September 22, 2007 Posted September 22, 2007 Mm.. I really don't know why that happens. But if the window title is always the same, use: Opt("WinTitleMatchMode",4) $WinList=WinList("classname=CabinetWClass") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) Next WinClose("script_folder") just a suggestion.
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 If you want to close the Windows Explorer windows (Like, my documents, my music, whatever) this works:Opt("WinTitleMatchMode",4) $WinList=WinList("classname=CabinetWClass") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) NextFor Internet Explorer windows:Opt("WinTitleMatchMode",2) $WinList=WinList("- Internet Explorer") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) NextFor the Internet Explorer windows the code should be changed a little:Opt("WinTitleMatchMode",2) $WinList=WinList("Internet Explorer") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) NextThere was a typo in the name.But your first script does not want to close the folder where the script is yet. Can't figure out myself.
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 Mm.. I really don't know why that happens. But if the window title is always the same, use: Opt("WinTitleMatchMode",4) $WinList=WinList("classname=CabinetWClass") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) Next WinClose("script_folder") just a suggestion. Now it is weird. It still does not want to close the folder where the script is: WinClose("script_folder")
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 Now it is weird. It still does not want to close the folder where the script is: WinClose("script_folder") Ok it works now , but I put extra \ like c:\2\ - it did not close. I changed to c:\2 it closes now. Still it is a partial solution.
Nahuel Posted September 22, 2007 Posted September 22, 2007 *tries* Wait, it does close the folder the script is in here Download Autoit latest version, haha. Who knows..
Nahuel Posted September 22, 2007 Posted September 22, 2007 Ok it works now , but I put extra \ like c:\2\ - it did not close. I changed to c:\2 it closes now. Still it is a partial solution.But you have to use the title, not the path.
Dirk98 Posted September 22, 2007 Author Posted September 22, 2007 But you have to use the title, not the path. Nahuel, I've fixed it. You put the wrong class there. No need for WinClose("script_folder") anymore. Opt("WinTitleMatchMode",4) $WinList=WinList("classname=ExploreWClass") For $b=1 to $WinList[0][0] WinClose($WinList[$b][0]) Next This one is perfect now. I really wish I understood how to program not to just to fix some typos. I didn't even have to think. Many thanks.
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