mark_miller66@bellsouth.ne Posted September 3, 2015 Report Share Posted September 3, 2015 SOMETIMES WHEN PERFORMING A SEARCH FOR PIXELS - THE PIXELS CANNOT BE FOUND - THE USER MUST STOP THE ROUTINE MANUALLY BY PRESSING PAUSE OR CLICKING ON THE GREEN MAN. THIS ROUTINE IS DESIGNED TO TIME OUT A SEARCH FOR A SET PIXEL COLOR AT AT SET LOCATION WITH A SET COLOR. THE ELAPSED TIME IS SET (IN THIS CASE TO 10SEC). IF THE PIXEL COLOR IS NOT FOUND AT THE SET LOCATION WITHIN 10 SECONDS THE SEARCH FOR PIXELS TIMES OUT There are certainly better ways to accomplish the same = please post. SEARCH FOR PIXEL TIME-OUT ROUTINE.mex Quote Link to comment Share on other sites More sharing options...
rberq Posted September 3, 2015 Report Share Posted September 3, 2015 I generally write a repeat loop with a short delay within the loop. Delay time multiplied by number of repeats equals the (nominal) total time to wait, but if the expected color appears the wait is ended immediately. Here's a wait of zero to ten seconds. REPEAT START 100 TIMES GET PIXEL COLOR AT n1,n2 INTO n3 IF n3 = 1234567 REPEAT EXIT ELSE DELAY100ms (one tenth of a second) END IF REPEAT END * We may exit from the loop when the color is found, or after the maximum repetitions. Therefore the check below * figures out whether the color was found or not. IF n3 NOT = 1234567 TEXT BOX DISPLAY not-found message MACRO END END IF Maybe no "better" than your method, just another way of doing it. I'm not sure what you are asking for -- a way to end the wait early without killing the macro??? Quote Link to comment Share on other sites More sharing options...
Cory Posted September 4, 2015 Report Share Posted September 4, 2015 I'm with Rberg on this one, you should at least have a small delay otherwise it will do it millions of times a second and could pack up the system. I would try that first. Next I would log what the color actually is in each iteration of the loop and see if it's actually ever seeing that color. The color you have specified is very specific and these days with blends, shadows, and textures of graphic components you need to be more flexible. I was trying to detect the green in a progress bar once but I counted hundreds of shades of green. I wrote about this on the forum and may still have a web page dedicated to colors in MEP on my site. But essentially I would break the color into RGB components and evaluate them. So if I wanted something that was mostly green I might look for a green value greater than 200 and red and blues less than 50. If you need help with this please let me know. But first you should check to see what colors MEP is actually seeing at those coordinates. 1 Quote Link to comment Share on other sites More sharing options...
mark_miller66@bellsouth.ne Posted September 4, 2015 Author Report Share Posted September 4, 2015 Thank you both. You help me see other issues which I blindly ignore such as nuance in pixel colors and in overloading the processor. You guys are brilliant! Quote Link to comment Share on other sites More sharing options...
rberq Posted September 4, 2015 Report Share Posted September 4, 2015 Speaking of pixel colors, I was trying to find the slider within the vertical scroll bar by looking at pixel color. I discovered that ME apparently does not see variations in color within the scroll bar. Or at least it is not seeing anything like the same color variations that my eye sees. Try it by turning on the Mouse Locator tool and see what I mean. What's that about??? (I have Windows 7 running ME3.) Quote Link to comment Share on other sites More sharing options...
acantor Posted September 5, 2015 Report Share Posted September 5, 2015 Hi rberq, Curious. Try changing the display theme from whatever it is (probably one of the "Aero" themes) to "Classic..." Control Panel\All Control Panel Items\Personalization ...and test whether you can detect pixels in the scroll bars. Quote Link to comment Share on other sites More sharing options...
acantor Posted September 5, 2015 Report Share Posted September 5, 2015 When I am testing pixel colours and want to include a time-out, I try to choose a value that makes some logical sense. For example, if I am checking horizontally one pixel at a time, I use the window width. If I am checking horizontally every ten pixels, I use the window width divided by ten. Set Variable %x% = 0 ' Start checking pixels at (0, %y%) Set Variable %y% = 100 ' Constant distance as measured from top of the window Set Variable %WindowWidth% = width of window Repeat %WindowWidth% times Set Variable %PixelColour% at %x%, %y% If %PixelColour% = 123456 Then Exit Repeat Else Increment %x% End if Repeat End I start by including delays, but once the macro is working, I try to get rid of them. There are circumstances when a short delay (5 ms? 100 ms?) at each iteration is essential. 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.