nkormanik Posted July 12, 2018 Report Share Posted July 12, 2018 I see lots of options for repeating a loop within a macro. But not a way to do it for a specific amount of time. Suppose we want to repeat a loop for 30 seconds. Then stop that loop, and continue onto the next part of the macro. Can we do this? How? Thanks much! Nicholas Kormanik Quote Link to comment Share on other sites More sharing options...
acantor Posted July 12, 2018 Report Share Posted July 12, 2018 I think the best you will be able to do is repeat an action x times, with a delay within the loop. You would have to experiment with the number of repeats and delays to take 30 seconds. A loop repeated 30 times with a one second delay would be a good place to start. Quote Link to comment Share on other sites More sharing options...
Cory Posted July 12, 2018 Report Share Posted July 12, 2018 Sure there is. It's called Repeat Until. Set a time variable value to 30 seconds in the future before the loop begins. Set the time in a second variable in the loop. Then use the "greater than" comparator. Quote Link to comment Share on other sites More sharing options...
rberq Posted July 12, 2018 Report Share Posted July 12, 2018 3 hours ago, Cory said: Sure there is. It's called Repeat Until. Set a time variable value to 30 seconds in the future before the loop begins. Set the time in a second variable in the loop. Then use the "greater than" comparator. Great idea! Too easy! I tend to use acantor's technique, but of course that only approximates the duration. In any case I think it's a good idea to have a delay inside the loop, even if a very short one, on the theory that the delay releases control to Windows so the computer can do something else during the REPEAT loop rather than just a CPU-bound loop. Of course I don't know if that's how ME interacts with Windows, but I contend it's a good theory in any case. ? For most "wait" loops I use 100ms as the delay, since 1/10 second is almost imperceptible to the user. Additionally, a timed delay is independent of processor speed, so the macro will appear to run more-or-less the same on older vs. newer PCs. Quote Link to comment Share on other sites More sharing options...
nkormanik Posted July 13, 2018 Author Report Share Posted July 13, 2018 Some actual code, please. Sounds basic, until one tries to do it. Quote Link to comment Share on other sites More sharing options...
rberq Posted July 13, 2018 Report Share Posted July 13, 2018 This logic waits for up to approximately 20 seconds (200 tenths). As soon as screen colors match the expected values, it exits from the REPEAT loop. If colors do not match within 200 iterations, it also falls through the REPEAT END to whatever instructions follow. // wait 20 seconds for switch to password screen (monitor for change from blue to white, and for Submit button (gray)) Repeat Start (Repeat 200 times) Get Pixel: Screen Coords: 600,565 into %N1% Get Pixel: Screen Coords: 268,466 into %N2% If Variable %N1% = 16777215 AND If Variable %N2% = 13160660 Repeat Exit Else Delay 100 Milliseconds End If Repeat End Quote Link to comment Share on other sites More sharing options...
nkormanik Posted July 13, 2018 Author Report Share Posted July 13, 2018 Good code. Thanks! But the desperately needed info is how to get TIME PASSED into a variable. 30 seconds. Or time counts up to 30 seconds. In a variable. So far, can't find it. Seems Macro Express Pro left it out. Go figure. Quote Link to comment Share on other sites More sharing options...
rberq Posted July 14, 2018 Report Share Posted July 14, 2018 Variable Set Integer has options to load current hour or minute or second into variables. Also experiment with the Date and Date/Time commands. Quote Link to comment Share on other sites More sharing options...
nkormanik Posted July 14, 2018 Author Report Share Posted July 14, 2018 Plain sneaky. What's it doing hiding there?? Quote Link to comment Share on other sites More sharing options...
rberq Posted July 14, 2018 Report Share Posted July 14, 2018 5 hours ago, nkormanik said: Plain sneaky. What's it doing hiding there?? ? I have been using ME for years and I still stumble onto hidden stuff like that. Quote Link to comment Share on other sites More sharing options...
Cory Posted August 1, 2018 Report Share Posted August 1, 2018 On 7/14/2018 at 12:19 AM, nkormanik said: Plain sneaky. What's it doing hiding there?? RTFM. LOL. JK. 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.