Jump to content
Macro Express Forums

Activate all Win Explorer Windows


Recommended Posts

Hey everyone,

 

how do I activate all opened WinExplorer Windows? Their window title have different names depending on which folder is open. I tried to activate "explorer.exe" which I thought would be the application behind the WinExplorer windows, but that doesn't work.

 

Is that even possible?

Link to comment
Share on other sites

I don't think it's possible because of how Windows works. You can only interact with one window at a time. That window is the active window.

 

Other windows may be visible, but they are in the background. You can't interact with a non-active window until you give it focus by clicking on it or switching to it via keyboard.

 

It may be possible to write a macro that, when activated, brings up an instance of File Explorer. Activate the macro again, and the macro brings up another instance of File Explorer, if there is one. And so on.

Link to comment
Share on other sites

So it's not possible like, having multiple Chrome windows, and making them visible via "set window order" or activating them one after another, because Chrome always has Chrome in all of it's window titles. While WinExplorer windows always have the current opened folder as window title, correct?

Link to comment
Share on other sites

Although this is not a perfect solution, this script activates each instance of File Explorer, one after another. So if you have ten windows open, and five of them are File Explorer, running the macro will place the five File Explorer windows on top of the stack.

 

There are plenty of problems with this script:

 

1. The macro enumerates any window that includes "c:\" in its title bar. Therefore, the macro misidentifies all non-File Explorer windows that have "c:\" in their titles.

 

2. The macro misses File Explorer windows for non-c: drives, like "d:\" or "z:\". You might try to fix this by changing the target title from "c:\" to ":\" but I can imagine this might introduce all sorts of side effects.

 

3. The macro misses named File Explorer folders, like "This PC" and "Documents". However, I believe there is a registry hack that toggles off named folders.

 

4. The stop rule is ugly. If Line 5 (Window activate) fails because the window doesn't exist, the macro handles the error by bringing everything to a screeching halt. But I can live with this aesthetic blemish if others can.

 

Hopefully someone can improve the script.

 

Variable Set Handle %WinTitle% from all windows with the title of "C:\"
Get Array Length (%WinTitle%) => %Count%
Variable Set Integer %x% to 1
Repeat Start (Repeat %Count% times)
  Window Activate: %WinTitle[%x%]%
  On Error
    Catch Error: Window could not be found
      Macro Stop
    End Catch Error
  End Error
  Variable Modify Integer %x%: Increment
End Repeat

<VARIABLE SET HANDLE Option="\x00" Info="C:\\" Partial="TRUE" Wildcards="FALSE" Destination="%WinTitle%"/>
<GET ARRAY LENGTH Array="%WinTitle%" Dest="%Count%"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="1"/>
<REPEAT START Start="1" Step="1" Count="%Count%" Save="FALSE"/>
<WINDOW ACTIVATE Title="%WinTitle[%x%]%" Exact_Match="FALSE" Wildcards="FALSE" _HANDLE="0x0006"/>
<ON ERROR/>
<CATCH ERROR Code="6"/>
<MACRO STOP/>
<END CATCH ERROR/>
<END ERROR/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%x%"/>
<END REPEAT/>

 

Link to comment
Share on other sites

Thank you very much for your input. Actually it never happens that "C:"\ is in the title as the window title shows only the current folder name. I guess i have to define a handle variable for each instance of win explorer like %ex1% to %ex5% to "handle" those windows reliable. This also has the advantage that i can adress each window individually which might be useful.  😉

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...