BBO Posted November 6, 2020 Report Share Posted November 6, 2020 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. Quote Link to comment Share on other sites More sharing options...
acantor Posted November 22, 2020 Report Share Posted November 22, 2020 I suggest re-doing the three lines. You can comment out the originals, or delete them. Then recreate the three lines from scratch. I'm not convinced the logic you've outlined is what is needed. Also, Windows 10 File Explorer has a lot of focus-related problems that might be throwing off a script that was developed for earlier versions of Windows. If you are making changes in the File Explorer window while the File Explorer is active, I don't think you need to activate the window. Maybe if renaming is taking time that is throwing of the synchronization, a refresh might be a better option. I believe the built-in hotkey for this is F5. So maybe something like this: Quote Text Type (Simulate Keystrokes): <F2> // Hotkey to rename a file or folder Delay: 100 milliseconds // You may or may not need a short delay Text Type (Simulate Keystrokes): Hello // Enter the new name Text Type (Simulate Keystrokes): <ENTER> // Finalize the rename Text Type (Simulate Keystrokes): <F5> // Refresh the screen, if needed Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.