Sign in to follow this  
Followers 0
Sumoman

Shade Variation

11 posts in this topic

I'm having a very hard time trying to use autoIT's pixelsearch and pixelgetcolor to read text in a graphics window.

(I know, I know. I have been previously told that autoIT is not optical recognition software, but unless autoIT can work with an OCR [which i'll have to research in the meantime] then i'm going to have to stick with pixelsearch).

My problem is that the text always appears to be white, but the spywindow gives me a different deci-color everytime the text is refreshed.

So I was wondering how I make pixelsearch for 1 pixel, and also how to work with the shade variation variable (i.e. how large of a variation is large enough to cover all of these different whites)

Share this post


Link to post
Share on other sites



I was wondering how I make pixelsearch for 1 pixel

Just have the left & right values be the same, and the top & bottom values also the same. Then it will only run the pixelsearch on that one pixel.

and also how to work with the shade variation variable

Define the shade variation optional paramater somewhere between 1 and 255. The number you choose will depend on how much variation you see when you use the Spy to get the shade of white your text is. 255 (the maximium) converts to FF in hex, so that would detect all colors in the shade variation (which is not practically useful.) Basically, you want a shade variation slightly higher than the largest varition you see in the 2 digits of the hex number that change when you view different whites with the spy.

Example:

Suppose you get a range of white colors from FFFF90 to FFFFFF, you could use pixel search for the value of FFFFC0 (the average) with a shade variation of 60 (a bit more than the 48 that my example varried.) I get 48 by noting the difference between the average hex color, and converting that to decimal. FF - C0 = 30. In decimal, 0x30 is 16 * 3, which is 48. Go slightly larger than this because the range of colors you detected may not represent the whole range that exists for the color of your text.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Can i use deci to determin my shade variation?

Because the shade variation i was seeing with decimal was changing even the 2nd digit, so i don't know if 255 would be enough...

edit: i'll try hexa first though,

how do i convert from hexa to deci though?

is 0-9 then a-f?

Edited by Sumoman

Share this post


Link to post
Share on other sites

The color code works like this:

There are 3 colors that are combined to make any color you see: Red, Green, and Blue. This is expressed as a 6 digit hex number, and each 2 digits of the hex number represent a color. So the hex number 00FF00 means full green, and no other color (first 2 zero's mean no red, the F's mean full green, and the last zero's mean no blue.) Now, each set of 2 hex digits represents a number from 0 to 255. To get the number, take the number in the 1's place (right digit of each set) plus 16 times the 16's place (the first number of each set.) So 0x01 = 1, 0x10 = 16, etc.

What it means

The variation is just how much you want to allow each color to extend to when you use your pixel search. So if you gave it the number 666666 to search, but also wanted to include numbers up to 668866, you should enter a variation of 0x22 (the difference between the 0x66 and 0x88 in the green color) which is a decimal value of 2 + 16 * 2, or 34. Remember, it's usually a good idea to go a bit outside of the range you discovered in the spy, just because your spy detection may not have include all potential variations of the colors.

I hope this made it a bit clearer for you and not more confusiong :D


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

edit - stupid question >.< here's a better one

how does pixel search determine whether to search in Deci or hexa?

Also: my search came with FFFFF8 and FFFFFF, that = 8 variation right? so if I go with 16 would that work?

edit... AGAIN >.<

is it the "0x" FFFFFF that's the flag for hexa?

edit.... just in case i haven't edited it enough :D

how do i set @error back to 0 if pixelsearch sets it to 1

Edited by Sumoman

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

my other problem with this shade variation is that the hexa string for some of the colors is really complex (i.e. 175B19) and i'm having trouble averaging all of the numbers....

here's some raw data i'm getting from just 1 color of text

2D9A2D

175B19

271100

21FF7C

21FF57

I'm gonna work on averaging these and see what i can come up with >.<

edit:

If I did all the calculations right (which i prob didn't >.<) then the colors would look like this:

46 155 46

24 92 26

40 18 0

34 256 125

34 256 88

That's a pretty big range o.0

Edited by Sumoman

Share this post


Link to post
Share on other sites

how does pixel search determine whether to search in Deci or hexa?

Whatever you enter it in. You can use decimal, but it's a lot harder to read. Just use "0xABCDEF" for your color so that you can see the proper Red/Green/Blue portions of the color. It makes the math a lot eaisier.

Also: my search came with FFFFF8 and FFFFFF, that = 8 variation right? so if I go with 16 would that work?

Yup, if that's all your variation is. Should be fine there. If not, try adjusting the value higher to get all the shades you require.

is it the "0x" FFFFFF that's the flag for hexa?

Yup, here is a hex number: "0xAB", and here is that in decimal: "171"

how do i set @error back to 0 if pixelsearch sets it to 1

@error reports the success or failure of the last command used. There is no need to set it back to 0 because the next function that you call will set it again depending on the success or failure.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Wait... i thought the primary colors were Red, blue, and yellow.... don't blue and yellow make green? :D

But the colors you listed make sense for my results (the text color i'm having trouble with is greenish).

Still... the hex values for my text are all over the place, I want to be able to distinguish between the White text, the green text, and the black-grey-blue background.

Any ideas of how to get this green text?

Share this post


Link to post
Share on other sites

Wait... i thought the primary colors were Red, blue, and yellow.... don't blue and yellow make green?  :D

Not when you're talking about light. It depends on what version of AutoIt you use, but 3.0.102 uses RGB. 3.0.101 and lower used BGR.

Still... the hex values for my text are all over the place, I want to be able to distinguish between the White text, the green text, and the black-grey-blue background.

Why not figure out if your test has a lot more green than anything else. If not, figure out if it's a lighter color, or a darker color to distiunguish between the light white color, and a dark background color.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

another weird problem i'm having:

for some reason the line

Send("!1")

doesn't always work. But sometimes it does....

Share this post


Link to post
Share on other sites

for some reason the line

Send("!1")

doesn't always work.  But sometimes it does....

That's a global send, so unless your target application or control is active (and stays active), it may not do what you expect.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0