Jump to content
Macro Express Forums

Exiting A Repeat Until [elapsed Time]


MGuyM
 Share

Recommended Posts

I have a macro that I wrote do automatically click on certain locations within a program. However, after the Click, I have to wait for the Screen to Redraw and display a message for my Macro to click on the Close Button.

 

Problem I'm running into is that usually, everything runs great. But sometimes the Redraw doesn't take place. I currently check for the Change of a Pixel using the following routine:

 

Get Pixel: Window Coords: 430,275 into %N1%
Repeat Until %N1% = 1071789
 Wait Time Delay 0.5 Seconds
 Get Pixel: Window Coords: 430,275 into %N1%
 If Variable %N1% = 1071789
   Repeat Exit
 End If
Repeat End

 

What I'd like to add to this is a secondary check for an elapsed amount of time and then exit but I'm not sure how to implement the second level and was hoping that someone could help me (most likely Cory) :)

 

Basically, if my screen doesn't redraw properly, my Macro hangs in the above loop waiting for the Pixel at 430,275 to change. When this happens, I can move the mouse around the location to allow the change to be seen and my macro continues. However, If I do a for loop to move the mouse around this location, it doesn't seem to work.

 

I'm thinking that if there is a way to get a "TIME" when the First Get Pixel is recorded into %N1% and then during my Repeat Loop, do a Check against the time to see if 1 Minute has elasped, then it could exit the Repeat Loop. But how do I evalute this????

 

I'll be waiting patiently for a response.... Thank You Very Much in Advance.

 

BTW.... Feel free to post the appropriate code :D

 

Sincerely!

MGuyM

Link to comment
Share on other sites

These changes will maximize your loop time to about 10 seconds. By changing the loop counter (%N2%) or the delay time (currently 0.5 seconds), you can increase or decrease the loop time.

Variable Set Integer %N2% to 1
Get Pixel: Window Coords: 430,275 into %N1%
Repeat Until %N1% = 1071789
  Wait Time Delay 0.5 Seconds
  Get Pixel: Window Coords: 430,275 into %N1%
  If Variable %N1% = 1071789
     OR 
  If Variable %N2% >= 20
     Repeat Exit
  End If
  Variable Modify Integer: Inc (%N2%)
Repeat End

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

×
×
  • Create New...