Jump to content

Closing multiple windows (by text match)


Recommended Posts

Hello, I'm having trouble trying to close some windows using WinClose, here's what I typed in the .au3 file:

WinClose ( "", "MountPoint" )

As the help file says, it will only close the most recent window if multiple windows match the criteria... so what do I do now?

"MountPoint" in this case is part of the path (full path F:\SYS\MountPoint\Flashdrive) I'm using to access the USB flashdrive instead of its real assigned letter I:, because WindowsXP does not save your view\layout preferences for removable media.

Reason I'm asking for this is because I started to use a neat application called USB Disk Ejector command line support to replace the native "Safely remove Mass Storage Device" process from Windows XP. Works great, but if I start the process to eject the flashdrive but there is one or more windows open pointing to the MountPoint\Flashdrive path, the process will fail, so I need to manually close them... then I remembered AutoIt could close windows and, and that's why I'm here :idea:, I failed to come up with a solution.

I've been using AutoIt for a while now, but only for basic stuff (just pasting commands like "FileCopy" and "Run" or using it as a replacement the XP command prompt), so please, don't get mad if the solution is simple and I just overlooked it somehow.

Edited by daisensou1979
Link to comment
Share on other sites

No worries!

I was getting some delay in the execution of the script, but solved that by adding the CLASS detail, so it would limit the search only on Windows err... windows.

I even solved partially the problem I was having with Windows not saving my view\layout preferences on removable media, by having AutoIt to open the path to the DVD drive and my flashdrive then resizing them to something that fit two columns in tiled view (forced system default). Now the only thing that doesn't work right is the "Sort by" thing, whatever I set as system default it is ignored whenever I access them, but that never did work right anyway.

Everything else is fine now. Thanks again!

While WinExists ("[CLASS:CabinetWClass]" , "MountPoint")
   WinClose ("[CLASS:CabinetWClass]" , "MountPoint")
Wend

Run ("C:\SysTools\USB.exe /showeject /removeletter I")
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...