Jump to content

Close open windows?


Dirk98
 Share

Recommended Posts

  • Moderators

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.

Link to comment
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? :)

:)

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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") :)

Link to comment
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.

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...