Jump to content
Macro Express Forums

W10 20H2 ME 5.2.0.1 Window Activate Error


Recommended Posts

Self-taught very basic Macro Express hack.
Been running ME for years.
Mostly to rename/number lists of files.
Upgraded to W10 & then ME 5.1 couple months ago.
Saw that when i upgraded to 5.1, the variables changed format from T%1% to %T[1]%, and the upgrade seemed to have automatically upgraded all my macro variables.
So far, so good. Everything kept working fine.
Then, about a week ago, when i went to run macros that have been running fine since the upgrades, i started getting this error:

 

The following error was encountered:
Undefined variable or the variable is the wrong type "20results"
Macro Name: File REPLACE jpeg with jpg
Line Number: 2

 

Here are the first three lines of that macro:

 

 VARIABLE SET STRING %T[6]% to topmost window title
 WINDOW ACTIVATE %T[6]%
 WAIT FOR WINDOW TITLE %T[6]%

 

I then upgraded from ME 5.1 to 5.2.0.1 - no change. Still getting the errors.

The thing is, they worked one day. Didn't work the next. These macros were written a long time ago, and have been running fine for years.

 

When i remove the VARIABLE SET STRING command and the remaining occurrences of the focusing algorithm:

 WINDOW ACTIVATE %T[6]%
 WAIT FOR WINDOW TITLE %T[6]%

the macros still work fine.

 

My goal with these lines is to focus the macro on the Windows Explorer window where the files are and then wait for it to be active. Otherwise, because sometimes the renaming changes the order of the files, and windows now insists on refreshing the view every time there's a change, sometimes the refresh takes longer than i have timed for in the macro, and the macro starts working on the wrong file. This was my solution since probably ME 2 or 3 to keep the macro and the window in sync.


What am i doing wrong? Is there a better way to do this? Any thoughts would be greatly appreciated.

 

 

 

Link to comment
Share on other sites

1 hour ago, BBO said:

 VARIABLE SET STRING %T[6]% to topmost window title
 WINDOW ACTIVATE %T[6]%
 WAIT FOR WINDOW TITLE %T[6]%

 

You may need to rethink the logic of your script. The first line captures the name of the topmost window. So far so good.

 

Then the second line activates the topmost window. So there may be nothing for the line to do. The window is already active.

 

Finally, the third line waits for the already active window to be appear. But the window was already there.

 

In Windows 10, there are a lot of focus-related problems associated with explorer.exe.  Sometimes one part of the UI receives focus when the window opens. Sometimes, a different part of the UI receives focus. Hovering the mouse over the File Explorer window can mess with focus. It's astonishing that Microsoft releases such misbehaving software!

 

I've spent far too many hours trying to repair these issues using Macro Express, with mixed success.

 

Not sure if this code sample will help, but the script, which is scoped to explorer.exe, usually gives focus to the list of folders and files in the right pane.

Quote

Mouse Move: -50, -50 Relative to Screen // Minimize mouse-over effect. (Mouse hovering over window causes focus problems?)
Text Type (Simulate Keystrokes): <F4> // Landmark in the Address field
Delay: 200 milliseconds
Text Type (Simulate Keystrokes): <SHIFT><TAB><SHIFT><TAB><SHIFT><TAB><SHIFT><TAB> // Navigate to the list of folders and files

 

 

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