|
Post by Johnc on Sept 30, 2018 3:27:42 GMT
Hi Steve,
I have a pixel color comparison loop to check a few pixels but sometimes the web page didn't load resulting in a dead lock in the loop. I need to time out the loop and then press the "refresh" button to get the page to reload and hopefully the right pixel condition will end the loop.
Any idea how to "time out" a loop in say 60 seconds?
Thanks! John
|
|
|
Post by Steve on Oct 2, 2018 0:16:23 GMT
Hi John, It really depends on what logic you are using to do your looping; it will be different for the FOR loop's or looping based on conditions. Generally you can't go wrong with a counter to control your looping
Something loosely like this for your 'time out' at 60 seconds: (opening macro lines) 10 | FOR | EACH | LINE IN | D:\Macro\pixel events.mmmacro | RUN 11 | RUN ACTION | WAIT SECONDS | 1 12 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::+1 13 | IF | INTEGER VARIABLE | %INTEGER% | < | 60 | GOTO MACRO LINE | 10 14 | FOR | EACH | LINE IN | D:\Macro\page refresh events.mmmacro | RUN 15 | IF | STRING VARIABLE | %STRING% | IS NOT | END | GOTO MACRO LINE | 10 (closing macro lines) - at line 10 we do the pixel conditions, loaded in using a FOR RUN condition - lines 11, 12, and 13 is our counter. We add +1 to INTEGER every loop. When we get INTEGER above 60 we move on to line 14 - line 14 we run the 'refresh' you need for the page, again in a FOR RUN condition. - and line 15, if we didn't declare STRING to END we then go back to line 10 and continue the loop Is this what your after John?
|
|
|
Post by Johnc on Oct 2, 2018 2:31:07 GMT
Thanks Steve for your help! This is exactly what I want and I have thought of doing something like this too. The wait 1 sec line is the key. I was hoping there is a timer function somehow without using a counter. This is a great example Steve!
U r the best! Thanks so much!
|
|
|
Post by Joe on Jan 28, 2022 21:24:00 GMT
Hi Steve
Can this be used if my run condition has a continue ?
|
|
|
Post by Steve on Jan 30, 2022 23:50:35 GMT
Hi Joe,
CONTINUE statements might not work here. Paste in an example of what you are trying to do and I will see if we can find an answer.
|
|
|
Post by joe on Jan 31, 2022 9:01:32 GMT
Hi Steve
i have a bunch of lines in the macro there is like 7 macro that test the pixel such as
29 | IF | PIXEL COLOR | Color [R=204, G=204, B=204]::At Location [X:1328 Y:306] | IS THE SAME | CONTINUE
if any of this 7 pixel colour check fails and ends checking condition indefinite loop, i wanna start from the beginning of the whole macro and start over
trying to upload 10,000 NFT on opensea, any suggestions
the page keeps erroring after every 15-20 mins
Thanks Steve
|
|
|
Post by Steve on Jan 31, 2022 22:20:38 GMT
Hi Steve i have a bunch of lines in the macro there is like 7 macro that test the pixel such as 29 | IF | PIXEL COLOR | Color [R=204, G=204, B=204]::At Location [X:1328 Y:306] | IS THE SAME | CONTINUE if any of this 7 pixel colour check fails and ends checking condition indefinite loop, i wanna start from the beginning of the whole macro and start over trying to upload 10,000 NFT on opensea, any suggestions the page keeps erroring after every 15-20 mins Thanks Steve Hi Joe, Something like this at the start of your macro code: * | PIXEL_CHECKS 1 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %RESTART%::FALSE 2 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1141 Y:879] | IS NOT THE SAME | DEFINE BOOLEAN VARIABLE | %RESTART%::TRUE 3 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1142 Y:880] | IS NOT THE SAME | DEFINE BOOLEAN VARIABLE | %RESTART%::TRUE 4 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1143 Y:881] | IS NOT THE SAME | DEFINE BOOLEAN VARIABLE | %RESTART%::TRUE 5 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1144 Y:882] | IS NOT THE SAME | DEFINE BOOLEAN VARIABLE | %RESTART%::TRUE 6 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1145 Y:883] | IS NOT THE SAME | DEFINE BOOLEAN VARIABLE | %RESTART%::TRUE 7 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1146 Y:884] | IS NOT THE SAME | DEFINE BOOLEAN VARIABLE | %RESTART%::TRUE 8 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1147 Y:885] | IS NOT THE SAME | DEFINE BOOLEAN VARIABLE | %RESTART%::TRUE 9 | RUN ACTION | WAIT MILLISECONDS | 100 10 | IF | BOOLEAN VARIABLE | %RESTART% | IS TRUE | GOTO MACRO LINE | PIXEL_CHECKS 1. We define a boolean variable, RESTART, and declare it to FALSE. 2 - 8. If the pixels from line 2 through to 8 are not the same as 255,255,255 then we set boolean RESTART to TRUE. 9. We wait 100 milliseconds at the end. This may not seem important but it is. It helps to slow down the macro. MMM will run through the pixel checks really fast. If you have the internal MMM event logger on it will spam hard here with internal logging events. If you don't want to wait the 100 ms then I suggest turning off the internal MMM event logger. You can do this from the MMM settings menu. 10. At line 10 we do a check to see if RESTART is TRUE. If it is true this means our pixels have changed, so we start again by GOTO MACRO LINE - PIXEL_CHECKS. 11. After line 10 we would have the guts of the code whatever that may be for you. Hope this helps.
|
|