Sign in to follow this  
Followers 0
Dirk98

Close open windows?

25 posts in this topic

Guys, how to script "close all open instances of Explorer and IE browser" only but don't touch other application windows?

Thanks.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

Maybe using ProcessClose("iexplore.exe").

Alternate method:

$WinList=WinList("- Internet Explorer")

For $b=1 to $WinList[0][0]
    WinClose($WinList[$b][0])
Next

Share this post


Link to post
Share on other sites

Thanks, guys, for the IE tip.

I also meant to close all open file folders. How to do that?

Thanks.

Share this post


Link to post
Share on other sites

Hum, like this? :)

Opt("WinTitleMatchMode",4)
$WinList=WinList("classname=CabinetWClass")

For $b=1 to $WinList[0][0]
    WinClose($WinList[$b][0])
Next

Share this post


Link to post
Share on other sites

Use this for close the file folders

Global $aPL = ProcessList("explorer.exe")
For $iCC = 1 To $aPL[0][0]
    ProcessClose($aPL[$iCC][1])
Next
Won't this terminate explorer causing the desktop to go blank? :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Use this for close the file folders

Global $aPL = ProcessList("explorer.exe")
For $iCC = 1 To $aPL[0][0]
    ProcessClose($aPL[$iCC][1])
Next

Won't this terminate explorer causing the desktop to go blank? :)

:)

Guys, can anyone try out this code please? :P

No, pls don't do that, just messing.

Seriously, will that code close explorer.exe process indeed? No good.

Edited by Dirk98

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by Nahuel

Share this post


Link to post
Share on other sites

:)

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

Share this post


Link to post
Share on other sites

#11 ·  Posted (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.

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 by Dirk98

Share this post


Link to post
Share on other sites

#12 ·  Posted (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])
Next
SmokeOn: 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 by Dirk98

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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
For 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])
Next

There 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.

Share this post


Link to post
Share on other sites

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") :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

*tries*

Wait, it does close the folder the script is in here :)

Download Autoit latest version, haha. Who knows..

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

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