Jump to content
Macro Express Forums

Why doesn't this work?


Recommended Posts

This has been vexing me for ages, so I'd appreciate it if someone can see why it's not working please.

 

You may remember I recently posed the problem of how to restore a set of Explorer/My Computer folders from a 'grouped' taskbar entry (because Windows surprisingly lacks such a facility). I subsequently wrote the following macro that should do it IMO. But it produces erratic results. Sometimes only a few of the windows open and the macro continues running. Sometimes the macro finishes but there's just one of many windows not opened.

 

In case it's not clear, the macro opens all visible windows one by one, tests to see if the title matches the criteria for an Explorer folder (but excludes my text editor window, which would also qualify otherwise), then activates that window.

 

// Assumes titles show full path

Repeat with Windows: Visible Windows: Store in variable CurrentWindow

// Activate only Explorer folders, which can be identified by containing the string ':\'

If Variable %CurrentWindow% Contains ":\" // An Explorer window (assuming title shows full path)

And

If Variable %CurrentWindow% Does not Contain "Latest - TextPad" // This ensures that my text editor does not get included, despite having a title like

'Latest - TextPad - [C:\Docs\SUNDRY\Desktop Layouts\Test .txt]'

Window Activate: %CurrentWindow%

Wait for Window Title: %CurrentWindow%

End If

Delay: 200 milliseconds

End Repeat

 

CODE

<COMMENT Value="Assumes titles show full path"/>

<REPEAT WITH WINDOWS ToRetrieve="\x01" SortOrder="\x00" Destination="CurrentWindow"/>

<COMMENT Value="Activate only Explorer folders, which can be identified by containing the string ':\\'"/>

<IF VARIABLE Variable="%CurrentWindow%" Condition="\x06" Value=":\\" IgnoreCase="FALSE" _COMMENT="An Explorer window (assuming title shows full path)"/>

<AND/>

<IF VARIABLE Variable="%CurrentWindow%" Condition="\x07" Value="Latest - TextPad" IgnoreCase="FALSE" _COMMENT="This ensures that my text editor does not get included, despite having a title like\r\n'Latest - TextPad - [C:\\Docs\\SUNDRY\\Desktop Layouts\\Test .txt]'"/>

<WINDOW ACTIVATE Title="%CurrentWindow%" Exact_Match="FALSE" Wildcards="FALSE"/>

<WAIT FOR WINDOW TITLE Title="%CurrentWindow%" Partial="FALSE" Wildcards="FALSE" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>

<END IF/>

<DELAY Flags="\x02" Time="200"/>

<END REPEAT/>

 

 

To test it I just open a set of 8-10 My Computer folders (with full paths shown in titles), arrange them to suit me, minimise some of them, hide others (e.g. with my browser), and then run the macro. I want and expect all folders to appear just as they did originally, with none hidden. But I'm darned if I can do it. :(

 

Replacing the Wait with a Delay doesn't seem to help, nor does adding extra delays. Hope someone here can spot the flaw!

 

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

I can't see any code that deals with windows that are not visible.

 

Why is that relevant? I don't want to see any 'Hidden' windows, if that's what you mean by 'not visible'. All open Windows Explorer folders are 'Visible' windows and those are the only ones I want to restore.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

I'm glad a have a very wide screen to read this post! :)

 

I don't have time to play with this and can only offer speculation so take this with a big grain of salt.

 

One problem with "Repeat With Folder" is when you want to rename a bunch of files. If you are renaming the items that you are basing the cycle with it gets out of whack quick. ME does not make a list then execute but rather appears to return to the folder each time and reevaluate. The results are as you describe with winodws. I wonder if the fact that you are activating them is somehow changing the order and causing some to be missed. Try this. Do one repeat loop where you create a list of window titles then a second loop that plows thru that list doing what you need to do. This way you're not trying to hit a moving target.

Link to comment
Share on other sites

I'm glad a have a very wide screen to read this post! :)

 

I don't have time to play with this and can only offer speculation so take this with a big grain of salt.

 

One problem with "Repeat With Folder" is when you want to rename a bunch of files. If you are renaming the items that you are basing the cycle with it gets out of whack quick. ME does not make a list then execute but rather appears to return to the folder each time and reevaluate. The results are as you describe with winodws. I wonder if the fact that you are activating them is somehow changing the order and causing some to be missed. Try this. Do one repeat loop where you create a list of window titles then a second loop that plows thru that list doing what you need to do. This way you're not trying to hit a moving target.

 

Thanks Cory. I've edited the original to avoid the horizontal scrolling requirement, which I dislike too. I'll use that method from now on, assuming there's no problem? I'm hoping PGM might get around to fixing this and other forum issues soon, as discussed in the thread http://pgmacros.invisionzone.com/index.php?showtopic=3711 including the silly inability to search for 3-character words.

 

Re the macro, I don't do any renaming in this, I just simply activate each window in turn. I'll play with it a bit more and try your suggestion, but I'm about ready to give up on it. Just doesn't seem to make any sense. If anyone else has time to experiment, here's a simplified version:

 

Repeat with Windows: Visible Windows: Store in variable CurrentWindow

If Variable %CurrentWindow% Contains ":\" // An Explorer window (assuming title shows full path)

Window Activate: %CurrentWindow%

Wait for Window Title: %CurrentWindow%

End If

Delay: 200 milliseconds

End Repeat

 

<REPEAT WITH WINDOWS ToRetrieve="\x01" SortOrder="\x00" Destination="CurrentWindow"/>

<IF VARIABLE Variable="%CurrentWindow%" Condition="\x06" Value=":\\" IgnoreCase="FALSE" _COMMENT="An Explorer window (assuming title shows full path)"/>

<WINDOW ACTIVATE Title="%CurrentWindow%" Exact_Match="FALSE" Wildcards="FALSE"/>

<WAIT FOR WINDOW TITLE Title="%CurrentWindow%" Partial="FALSE" Wildcards="FALSE" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>

<END IF/>

<DELAY Flags="\x02" Time="200"/>

<END REPEAT/>

 

You just need to open a bunch of folders (on the C: drive unless you change the code of course), minimise a few, hide some or all with other applications, etc, and see if they all re-appear OK when you run the macro.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Sorted! :)

 

This was a salutary lesson for me. And it might be interesting to any others who have been casual about 'Exact Match' versus 'Partial Match' when specifying windows. I'd assumed that if I want to restore the window called C:\ABC\xyz then it's immaterial whether I use Partial or Exact. It should logically get activated whichever of those two options I use. Certianly, that's always been the case in other macros I've written in the past using Activate, Wait, etc (Of course, with Partial, other similarly named windows might also get activated, but there's no such ambiguity in the macro under discussion.). However, it turns out that my assumption was apparently incorrect.

 

Here are the results for all 4 combinations:

 

Window Activate: Partial

Wait for Window Title: Partial

Result: Fails (several windows don't get restored)

 

Window Activate: Exact

Wait for Window Title: Partial

Result: OK

 

Window Activate: Partial

Wait for Window Title: Partial

Result: Fails (macro never finishes)

 

Window Activate: Exact

Wait for Window Title: Exact

Result: OK

 

So, the macro works as long as the Window Activate command specifies Exact match, regardless of how the Wait command is specified.

 

I'd be interested to hear from ISS on the underlying cause of this please?

 

I suspect there are other situations as well as this Repeat with Windows loop where the same distinction applies.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Why is that relevant? I don't want to see any 'Hidden' windows, if that's what you mean by 'not visible'. All open Windows Explorer folders are 'Visible' windows and those are the only ones I want to restore.

Your original post states this:

To test it I just open a set of 8-10 My Computer folders (with full paths shown in titles), arrange them to suit me, minimise some of them, hide others (e.g. with my browser), and then run the macro. I want and expect all folders to appear just as they did originally, with none hidden.

I read this to mean you open a number of explorer windows (8-10), then minimize some and hide others. Then you run your macro, and want all the original windows to reappear with none hidden. Which I read to mean that you want to unhide those windows you had previously hidden or minimized.

That's why it's relevant.

Link to comment
Share on other sites

Your original post states this:

 

I read this to mean you open a number of explorer windows (8-10), then minimize some and hide others. Then you run your macro, and want all the original windows to reappear with none hidden. Which I read to mean that you want to unhide those windows you had previously hidden or minimized.

That's why it's relevant.

 

"...arrange them to suit me, minimise some of them, hide others (e.g. with my browser)..."

 

I think we're at cross-purposes. Do you mean the plain english meaning of 'hide' or the technical Windows attribute, used in ME Pro, called 'Hidden'. Your original post was a bit cryptic and I'd hoped my reply would have prompted some amplification. But I'm still not clear what you meant or mean?

 

The whole point of this macro is to re-display folders that may have become hidden by other windows, and - now that I've found that distinction about Exact & Partial that I've described, it works OK. What other code did you have in mind?

 

--

Terry, East Grinstead, UK

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

×
×
  • Create New...