Jump to content
Macro Express Forums

Add "wait for pixel color"...


Recommended Posts

  • 6 months later...

There is no "Wait for pixel color" so I made my own loop. Simply use the Get Pixel Color and put it in a loop with a delay and logic. I use a timeout as well to avoid an infinite loop. EG loop for 100 times with 100mS delay and a condition that when the color is found to break.

 

Be warned however it's probably not as simple as you think. Getting the pixel color is the easy part, making use of the integer 'representation' of it is not so easy. First off it's essentially 3 8 bit integer values glued together representing the 3 primary colors Blue, Green, Red in that order. IE black is 255, 255, 255 which will appear as 255255255 if memory serves. The reason I mention this is because in a modern OS GUI things like progress indicators are shaded meaning the exact color from one pixel to the next is slightly different. And because of the way the 3 values are glued together you can't really compare without first breaking them up. I have a webpage someplace explaining it all and there have been a few posts about it. If you get into it and need this edification let me know. Way to big to get into at this point.

Link to comment
Share on other sites

Cory,

Thanks for your reply.

I found a macro(umRGBColorEvaluator.mex). This macro tells you the color location of your mouse pointer. If you go through the script you'll find all the color combinations we can get through using RGB. When i run the macro it shows most of the time results as White color only.

Also you mentioned for Black color the color combination would be 255,255,255 where as in the macro script it is mentioned as 0,0,0.Unluckely i don't have the option to send you the script so i've attached the snapshot for your reference.
I tried to attach the snapshot of the script but the editor is not letting me to that as well.So i've mentioned the simple script for your reference.

<GET PIXEL COLOR Option="\x01" Rel_To_Screen="TRUE" X="482" Y="749" Destination="%pixel_color%"/>
<DELAY Flags="\x12" Time="300"/>
<END IF/>
<REPEAT START Start="1" Step="1" Count="200" Save="FALSE"/>
<DELAY Flags="\x02" Time="100"/>
<IF VARIABLE Variable="%pixel_color%" Condition="\x01" Value="255" IgnoreCase="FALSE"/>
<BREAK/>
<END IF/>
<END REPEAT/>
<TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Color Matched\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Gagan

Link to comment
Share on other sites

The color 16777215 / 0xFFFFFF / 255 255 255 is white while 0 / 0x000000 / 000 000 000 is black. Each number can vary between 0 and 255 and represents how much Red, Green and Blue to display. If the computer displays all red, green and blue possible you get white and if it displays no red, green and blue you get black.

 

Since colors are represented by numeric values it is possible create a "Wait for Pixel Color" function by creating a Repeat statement to wait until the value matches a certain color. In my macros I use OR statements to check for several colors. You need to be careful, though, because changing the Windows theme may require that you adjust your macro for the different colors.

Link to comment
Share on other sites

Gagan you're correct. I misspoke about FF, FF, FF being black. 255 = FF in hex BTW. Hex is much easier to deal with.

 

The snippet you sent is broken. Unmatched EndIf. But why do you need it? When I'm looking at colors I use the Mouse Locator tool. Right click the MEP tray icon > Tools > Launch Mouse Locator. It will show you the color under your mouse in integer and hex.

 

I don't see a question in your last post.

Link to comment
Share on other sites

  • 2 weeks later...

Cory,

 

I've used the below code to check the mouse pointer. It moves the pointer to the progress bar area of the application and wait till the time the app gets the focused back from the server. Once it gets the focus back it execute the next set of code. The color code 14215660 is blue color.

Mouse Move: 484, 729 Relative to Current Window
Get Pixel Color from Beneath the Mouse into %N[1]%
Repeat Until %N[1]% Equals "14215660"
  Mouse Move: 484, 729 Relative to Current Window
  Delay: 50 milliseconds
End Repeat

Any Suggestion ??

Link to comment
Share on other sites

Cory,

 

I've used the below code to check the mouse pointer. It moves the pointer to the progress bar area of the application and wait till the time the app gets the focused back from the server. Once it gets the focus back it execute the next set of code. The color code 14215660 is blue color.

Mouse Move: 484, 729 Relative to Current Window
Get Pixel Color from Beneath the Mouse into %N[1]%
Repeat Until %N[1]% Equals "14215660"
  Mouse Move: 484, 729 Relative to Current Window
  Delay: 50 milliseconds
End Repeat

Any Suggestion ??

Since you retrieve the pixel colour only once, your repeat statement will be executed either once only if the pixel colour is already blue, or for ever if it's not.. You need to include the Get Pixel Color command within the loop.

Link to comment
Share on other sites

Paul's right. Also I don't recommend you use the "Beneath the Mouse" method. Just get the pixel color at that position. Also I recommend a counter with a threshold in case the condition is never met. IE don't wait more than a set amount. Say 10 seconds.

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