Timing difficulties may make relying upon Wait for Window Title inadequate.
Timing difficulties may make relying upon Wait for Window Title inadequate, because conflicting commands are issued by the launch routine of a program Macro Express is launching.
My project was to create two macros for launching/activating three different programs and tiling them in two different ways, horizontally and vertically. Macro One launched or activated Forte Agent and SuperCat (a file cataloger) and attempted to tile them horizontally. SuperCat doesn’t need re-sizing or repositioning because it always launches in the in-between “restore” state, i.e., always taking up the top third of the screen, which was fine for my purposes. Macro Two minimized Supercat, launched NoteTab Light, and then re-sized and re-positioned Forte Agent so these latter two programs would be tiled vertically. (I use NoteTab Light to view a text-file report of Found Files produced by SuperCat to show me whether I’ve previously downloaded files.) During an Internet downloading session, I go back and forth with these two macros, using Win+1 and Win+2 to show and properly tile the three programs involved.
I was surprised that my Macro One’s Reposition and Resize commands had no effect upon Forte Agent whenever the macro launched Forte Agent. But, I discovered that the Reposition and Resize commands worked fine when I activated Forte Agent (after it was initially launched).
I tried to solve the problem by placing a command Wait for Window Title “Agent” above the Window Reposition and Window Resize commands for controlling Forte Agent. I expected Macro Express to wait for the window titled “Agent” to appear, and then issue the Reposition and Resize commands. That didn’t work.
My dilemma was that Macro One’s resize and reposition commands worked perfectly when Forte Agent was activated, but would not respond to Window Reposition and Window Resize commands when Macro One launched Forte Agent.
The problem turned out to be that Forte Agent, when it first launches, remembers the last size and position of its window in the previous Forte Agent session. Forte Agent’s own Reposition and Resize commands were not documented. Other programs I own have a set-up-option checkbox for such a feature, but not Forte Agent.
Forte Agent’s own launch routine takes a substantial amount of time, even after its window entitled “Agent” appears on the screen. Agent’s own re-size and reposition commands appear to occur in the final stage of its launch routine. When my macro detected the appearance of a window named “Agent”, my macro instantly issued its Reposition and Resize commands. Perhaps milliseconds later, Forte Agent’s own commands to reposition and resize its window to the size and position of the last Forte Agent session were issued. Forte Agent’s resize and reposition commands were thus “countermanding” my Macro One’s Reposition and Resize commands.
The above demonstrates why the “Wait for Window” command may be insufficient. There are other program routines at work whenever a program launches.
I knew I could solve the timing problem by inserting a Macro Express Delay command to follow the “Wait for Window” command. I found that a 2-second delay wasn’t long enough to make my Resize and Reposition macro commands work. However, a 3-second delay always made the Resize and Reposition commands work when Macro One launched Forte Agent.
But then I was left with an annoying, unnecessary 3-second delay whenever I used Macro One to merely activate Forte Agent. There was no need for this delay when activating Forte Agent, because Forte Agent doesn’t issue it’s own reposition and resize commands when activated.
I could have solved the problem with extra arguments in an If/Then/Else style, putting in a 3-second delay for launching of Forte Agent, but no delay when activating it. However, I solved the problem in a much easier way. I merely “Activate or Launch” Forte Agent at the beginning of Macro One, without following it with a delay or even a Wait for Window Title command. With Agent busily launching, I follow with other macro commands regarding control of the other two programs involved, such as Hide, Show, Activate or Launch commands for the other two programs as needed. By the time these Macro One commands are finished with the other two programs, Forte Agent has completed its launching routine, including issuance of its own resize and reposition commands. Forte Agent is now ready to accept my macro’s Resize and Reposition commands of its window. Now the Resize and Reposition commands in Macro One work perfectly, whether Agent is launched or activated.
– Applies to: Macro Express and Macro Express Pro