Jump to content
Macro Express Forums

Activate a Macro with Window Title only once


Recommended Posts

If you intended to have your macro wait 15 seconds after the Bookmarks window closes you should not use Macro Stop. No macro commands, including the Delay command at the end, will run after the Macro Stop command.  Instead use Break. That skips to the macro command after the End Repeat. However, in this case, neither Break nor Macro Stop is needed because setting T77 to Done will stop the repeat loop. Try something like this:

// Run the macro until the window is closed.
Variable Set String %T[77]% to "Not"
Repeat Until %T[77]% Equals "Done"
  If Not Window "Bookmarks - Google Chrome" is running
    Variable Set String %T[77]% to "Done"
  End If
  Delay: 100 milliseconds
End Repeat
Delay: 15 Seconds

You still need some delay inside the repeat loop for the reason stated above.

Link to comment
Share on other sites

Samrae,

 

My thinking on the 15 seconds may be wrong. I originally added the delay, because my macro kept going through the commands over and over again. Adding a 15s delay made that tolerable. Since I made the change you suggested, the macro keeps running, but does not continue playing the commands. So, I don't think the 15s delay is needed anymore.

 

After your last suggestion, I went with the 100 ms you show above and deleted the 15s delay. Everything froze again, and I had to log out. I changed the 100ms to 5000ms, and it seems to work OK for now.

 

// Get computer name!
Macro Run: !NA GLB Mini Tool, Get Computer Name
// Home Computer
If Variable %T[90]% Equals "ABRAHAM"
  Mouse Move: 135, 245 Relative to Screen
  Delay: 250 milliseconds
  Mouse Left Click
  Text Type (Simulate Keystrokes): <HOME>
  Text Type (Simulate Keystrokes): <ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ENTER>
  Delay: 250 milliseconds
  Text Type (Simulate Keystrokes): <TAB>
  Mouse Move: 920, 276 Relative to Screen
End If
// Work Computer
If Variable %T[90]% Equals "LUT4477"
  Mouse Move: 2700, 243 Relative to Screen
  Delay: 250 milliseconds
  Mouse Left Click
  Text Type (Simulate Keystrokes): <HOME>
  Text Type (Simulate Keystrokes): <ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ENTER>
  Delay: 250 milliseconds
  Text Type (Simulate Keystrokes): <TAB>
  Mouse Move: 3480, 276 Relative to Screen
End If
// Run the macro until the window is closed.
Variable Set String %T[77]% to "Not"
Repeat Until %T[77]% Equals "Done"
  If Not Window "Bookmarks - Google Chrome" is running
    Variable Set String %T[77]% to "Done"
    Macro Stop
  End If
  Delay: 5000 milliseconds
End Repeat

<COMMENT Value="Get computer name!"/>
<MACRO RUN Use_ID="FALSE" Name="!NA GLB Mini Tool, Get Computer Name" ID="-1" Wait="TRUE"/>
<COMMENT Value="Home Computer"/>
<IF VARIABLE Variable="%T[90]%" Condition="\x00" Value="ABRAHAM" IgnoreCase="FALSE"/>
<MOUSE MOVE Option="\x01" X="135" Y="245" _PROMPT="0x000A"/>
<DELAY Flags="\x02" Time="250"/>
<MOUSE LEFT CLICK/>
<TEXT TYPE Action="0" Text="<HOME>"/>
<TEXT TYPE Action="0" Text="<ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ENTER>"/>
<DELAY Flags="\x02" Time="250"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<MOUSE MOVE Option="\x01" X="920" Y="276" _PROMPT="0x000A"/>
<END IF/>
<COMMENT Value="Work Computer"/>
<IF VARIABLE Variable="%T[90]%" Condition="\x00" Value="LUT4477" IgnoreCase="FALSE"/>
<MOUSE MOVE Option="\x01" X="2700" Y="243" _PROMPT="0x000A"/>
<DELAY Flags="\x02" Time="250"/>
<MOUSE LEFT CLICK/>
<TEXT TYPE Action="0" Text="<HOME>"/>
<TEXT TYPE Action="0" Text="<ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ENTER>"/>
<DELAY Flags="\x02" Time="250"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<MOUSE MOVE Option="\x01" X="3480" Y="276" _PROMPT="0x000A"/>
<END IF/>
<COMMENT Value="Run the macro until the window is closed."/>
<VARIABLE SET STRING Option="\x00" Destination="%T[77]%" Value="Not" NoEmbeddedVars="FALSE"/>
<REPEAT UNTIL Variable="%T[77]%" Condition="\x00" Value="Done"/>
<IF NOT WINDOW Option="\x01" Title="Bookmarks - Google Chrome" Partial="TRUE" Wildcards="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%T[77]%" Value="Done" NoEmbeddedVars="FALSE"/>
<MACRO STOP/>
<END IF/>
<DELAY Flags="\x02" Time="5000"/>
<END REPEAT/>
 

Link to comment
Share on other sites

  • 7 months later...

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