Jump to content
Macro Express Forums

Intermittent failure - likely reason?


Recommended Posts

This macro should just open my Downloads folder and go to its end (which will usually be the most recent file, as I keep it sorted that way). For a decade I've run this scores of times without fail every day with a Stiletto macro, hotkey <Ctrl + Alt +D>. But as part of my tentative plan to phase out Stiletto I replaced it with this ME Pro macro a few weeks ago, same hotkey. About 20% of the time it opens and resizes/repositions the folder, but doesn't do the End command. What is the likely reason please? It's apparently losing focus, but how can that come about and why is it intermittent?

 

 

Open Folder to "C:\Docs\Downloads"

Delay: 100 milliseconds

Window Activate: C:\Docs\Downloads

Delay: 100 milliseconds

Wait for Window Title: C:\Docs\Downloads

Delay: 100 milliseconds

Window Reposition: <Current Window> Position: 1508, 5

Delay: 100 milliseconds

Window Resize: <Current Window> Size: 358, 776

Delay: 100 milliseconds

Text Type (Simulate Keystrokes): <END>

Delay: 100 milliseconds

 

For the curious, the Stiletto macro was this:

Command: D:\Docs\Downloads

Command Parameters: <*wait 1<"*Stiletto Exec" pos * 810 25 200 350<*wait 1<"*Keys" "{end}"

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

It would help if you were to supply MEP code instead of p-code!

 

OK, here you go:

 

<OPEN FOLDER Path="C:\\Docs\\Downloads"/>
<DELAY Flags="\x02" Time="100"/>
<WINDOW ACTIVATE Title="C:\\Docs\\Downloads" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
<DELAY Flags="\x02" Time="100"/>
<WAIT FOR WINDOW TITLE Title="C:\\Docs\\Downloads" Partial="FALSE" Wildcards="FALSE" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<DELAY Flags="\x02" Time="100"/>
<WINDOW REPOSITION Option="\x00" Partial="TRUE" Wildcards="FALSE" Method="\x00" Left="1508" Top="5" Monitor="0" _IGNORE="0x0006"/>
<DELAY Flags="\x02" Time="100"/>
<WINDOW RESIZE Option="\x00" Partial="TRUE" Wildcards="FALSE" Method="\x00" Width="358" Height="776" _IGNORE="0x0006"/>
<DELAY Flags="\x02" Time="100"/>
<TEXT TYPE Action="0" Text="<END>"/>
<DELAY Flags="\x02" Time="100"/>

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

1 Open Folder to "C:\Docs\Downloads"

2 Delay: 100 milliseconds

3 Window Activate: C:\Docs\Downloads

4 Delay: 100 milliseconds

5 Wait for Window Title: C:\Docs\Downloads

6 Delay: 100 milliseconds

 

Well, on my computer (XP Professional SP3), this never works because the window names are wrong!

My window is called Downloads instead of C:\Docs\Downloads!

Once I make this adjustment, it works perfectly every time.

 

And shouldn't lines 5 and 6 precede lines 3 and 4?

Link to comment
Share on other sites

1 Open Folder to "C:\Docs\Downloads"

2 Delay: 100 milliseconds

3 Window Activate: C:\Docs\Downloads

4 Delay: 100 milliseconds

5 Wait for Window Title: C:\Docs\Downloads

6 Delay: 100 milliseconds

 

Well, on my computer (XP Professional SP3), this never works because the window names are wrong!

My window is called Downloads instead of C:\Docs\Downloads!

Once I make this adjustment, it works perfectly every time.

 

And shouldn't lines 5 and 6 precede lines 3 and 4?

 

Thanks Paul. I think my problem with this macro (and probably a few others) is that I don't have a sound grasp of some important distinctions. Shouldn't opening a folder also Activate it, as it does when I open a folder manually?

 

But proof of the pudding ... I tried making the sequence change you pointed out, and now seem to be getting reliable operation, thanks!

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

And shouldn't lines 5 and 6 precede lines 3 and 4?

That's interesting because, like Terry, I have often been under the impression that activating a window was no guarantee that the window would be available. So I tend to follow my Activate commands with a Wait command as well.

 

Interesting.

Link to comment
Share on other sites

The way I read it is that opening the folder creates the window. As you can't be sure how long that will take, you then wait for the relevant window title to appear. Once it's present, you then activate it. If the window doesn't yet exist, then there's nothing to activate, which is the purpose of the waitfor command. I don't see that putting a waitfor command after the window has been activated achieves anything. I do agree with you that opening the folder should (and probably does) activate the window, but a belt and braces approach does no harm, and is good practice, especially with MEP.

Link to comment
Share on other sites

I would like to suggest you not use the Windows Explorer to do whatever with that file but rather do it all with MEP's file functions. Of course I don't know what you're doing with that file so...

Link to comment
Share on other sites

I would like to suggest you not use the Windows Explorer to do whatever with that file but rather do it all with MEP's file functions. Of course I don't know what you're doing with that file so...

 

The macro is operating on a folder, not a file.

 

The detail of what I'm doing was in my opening post. I'm simply viewing a folder so that I can see the last file downloaded. The most likely subsequent action, assuming it looks OK, would be to run it. Which hardly needs a macro!

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

By file I mean to include folder functions as well. I have many macros that do similar things but i use the macro to display exactly what is important to the user. For instance I might fire it on a download folder (common for log files) and show the user only the files that have changed since the last time they looked and given them the option of viewing the log files by selecting them. And of course by using the new folder monitoring activation I can have t lie in wait and not run until there is actually a change. Anyway it was just a suggestion. When I started making macros like this I often had issues similar to yours, especially in a distributed environ, and my solution was to simply do it all internally instead. It was so simple and reliable I never turned back.

Link to comment
Share on other sites

I've finally given up on this macro as it's so unreliable. I can never depend on it to give focus to the target folder. I've re-instated its Stiletto predecessor, which has run without fuss for a decade or more.

 

--

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...
×
×
  • Create New...