vorg Posted February 10, 2023 Report Share Posted February 10, 2023 Hello everyone, I'm trying to automate a task that involves waiting for a specific color to appear on a specific area of the screen for a maximum amount of time and then performing a set of actions. Is this possible with Macro Express? If so, how can I accomplish this? I have been using Macro Express Pro 6 for a while now and I love it. However, this is the first time I have come across a task that requires me to do this. I would greatly appreciate it if someone could guide me in the right direction. Thank you in advance for your help. Best regards, Vorg Quote Link to comment Share on other sites More sharing options...
acantor Posted February 10, 2023 Report Share Posted February 10, 2023 Repeat Start (Repeat 10 times) Mouse Move: 100, 200 Relative to Screen Get Pixel Color from Beneath the Mouse into %Pixel% If Variable %Pixel% Equals "123456" // Success. Do something. Repeat Exit Else Delay: 1000 milliseconds End If End Repeat Quote Link to comment Share on other sites More sharing options...
Cory Posted February 10, 2023 Report Share Posted February 10, 2023 There are many past topics in the forum regarding this. I even had some input on one that allows a macro to be tolerant of slight color variations. Quote Link to comment Share on other sites More sharing options...
vorg Posted February 10, 2023 Author Report Share Posted February 10, 2023 I tried a solution I found in the forum (this one), the thing is the macro seems to execute what i highlighted in green and stops (the green man running that indicate that a macro is running disappear) im new to this kind of macros, and never used macro return i don't see what i can do Quote Link to comment Share on other sites More sharing options...
Cory Posted February 10, 2023 Report Share Posted February 10, 2023 I don't know what's going on with that one. Acantor's is more what you want to look at. As I suggested, you need to make sure it's the exact color. There are thousands of shades of green. What does your picker say the color is and does it vary any? Quote Link to comment Share on other sites More sharing options...
vorg Posted February 10, 2023 Author Report Share Posted February 10, 2023 the color my macro search for is white and im sure that it's the exact color, i got the location and the color from another macro that already works for a different task, when i said "green" i was referring to what i highlighted on the image, the macro execute all that but it stops, normally as i understood the macro should return to the beginning of the macro when it sees macro return on the script, apparently it doesn't, it just stops Quote Link to comment Share on other sites More sharing options...
Cory Posted February 10, 2023 Report Share Posted February 10, 2023 What does Acantor's do with the correct value? Quote Link to comment Share on other sites More sharing options...
rberq Posted February 10, 2023 Report Share Posted February 10, 2023 2 hours ago, vorg said: i understood the macro should return to the beginning of the macro when it sees macro return on the script, apparently it doesn't, it just stops Macro Return means exit from the macro, NOT start over at the beginning of the script. A bit confusing, yes.... I like the script you listed, because it allows for the possibility that the correct color will NEVER appear. The Repeat loop looking for color will eventually end whether it finds the color or not. So if it ends without finding the color, you would never know -- except that the macro AGAIN double-checks the color after exiting or finishing the Repeat, and only if it ended successfully does it go on with its normal functions. When I say the Repeat loop will "eventually" end even if the color is not found, you will have to be very patient. One million repeats, with 1/5 second delay each time, may keep you up beyond your bedtime. If you want it to wait 30 seconds, say, before giving up -- then change the Repeat command to 150 instead of 1,000,000. Quote Link to comment Share on other sites More sharing options...
vorg Posted February 10, 2023 Author Report Share Posted February 10, 2023 3 hours ago, Cory said: What does Acantor's do with the correct value? Sorry for the wait, a good portion of my city lost power, we have some strong winds today. however i didn't try Acantor's script, now rberq told me that Macro return doesn't mean to start at the beginning of the script. Quote Link to comment Share on other sites More sharing options...
vorg Posted February 10, 2023 Author Report Share Posted February 10, 2023 1 hour ago, rberq said: Macro Return means exit from the macro, NOT start over at the beginning of the script. A bit confusing, yes.... I like the script you listed, because it allows for the possibility that the correct color will NEVER appear. The Repeat loop looking for color will eventually end whether it finds the color or not. So if it ends without finding the color, you would never know -- except that the macro AGAIN double-checks the color after exiting or finishing the Repeat, and only if it ended successfully does it go on with its normal functions. When I say the Repeat loop will "eventually" end even if the color is not found, you will have to be very patient. One million repeats, with 1/5 second delay each time, may keep you up beyond your bedtime. If you want it to wait 30 seconds, say, before giving up -- then change the Repeat command to 150 instead of 1,000,000. i tried with 100 150 200, the problem was that Macro Return wasn't for what i tough, my mistake didn't knew that. my question will be, there is a way to do that? making the macro to start over from the beginning without going over the whole script ? Quote Link to comment Share on other sites More sharing options...
acantor Posted February 10, 2023 Report Share Posted February 10, 2023 Yes, you can start at the beginning... :Start Repeat Start (Repeat 10 times) Mouse Move: 100, 200 Relative to Screen Get Pixel Color from Beneath the Mouse into %Pixel% If Variable %Pixel% Equals "123456" // Success. Do something and then stop Macro Stop Else Delay: 1000 milliseconds End If End Repeat // The colour was not found after ten seconds. Try again! Goto:Start ...but this kind of script can lead to a lot of mischief. I think it's better to have a fail-safe... If the colour is not found after a certain amount of time, the macro should simply stop. Otherwise, you risk an infinite loop. 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.