Jump to content
Sign in to follow this  
The Prince

PixelGetColor

Recommended Posts

The Prince

I have 4 digit changing numbers on screen, it cant be access using any formula in Autoit, Its in the same font type and size, the same background color, I analyses the difference to recognize the unique pixel structure of each number from 0-9, 8 pixel width; 12 pixel length, so according to the black pixel color I could identify the number; for example the second digit is number 1 if the pixel color in coordinate 425,140 (x,y) is black, the number is 2 if the pixel color in coordinate 424,148 (x,y) is black,etc, after determining the second number (the first is allways1), I go to the second region,+8 pixel from the second position, and we start the same steps.

Any ideas for improvement, adding loops for example, using offset formula since the coordinate to recognize each number are fixed in each 8X12 pixel rectangle region?

Thanks in advance

Opt("WinWaitDelay",10)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinActivate("xaxax1234,)

$color=16777215; Pixcel color to search
;first number is always 1
;    Recognizing the second number:-
$x=423; 
$x1=$x
$y=136
 
 $num21204=PixelGetColor($x+2,$y+4);chick if the 2nd number is 1 (if black color is in 2,4 coordanite)
 $num22112=PixelGetColor($x+1,$y+12);chick if the 2nd number is 2 (if black color is in 1,12 coordanite)
 $num23405=PixelGetColor($x+4,$y+5);chick if the 2nd number is 3 (if black color is in 4,5 coordanite)
 $num23603=PixelGetColor($x+6,$y+3)
 $num23604=PixelGetColor($x+6,$y+4)
 $num23429=PixelGetColor($x+2,$y+9)
 $num25203=PixelGetColor($x+2,$y+3)
 $num26206=PixelGetColor($x+2,$y+6)
 $num27411=PixelGetColor($x+4,$y+11)
 $num28205=PixelGetColor($x+2,$y+5)
 $num28306=PixelGetColor($x+3,$y+6)
 $num28406=PixelGetColor($x+4,$y+6)
 $num29308=PixelGetColor($x+3,$y+8)
 $num20107=PixelGetColor($x+1,$y+7)
 ;************************* 
  
 If $num21204==$color Then
  MsgBox(0,"Second Number is", 1, 5)
 ElseIf $num22112==$color Then
 ) MsgBox(0,"Second Number is", 2, 6) ElseIf ($num23405==$color And $num3363==$color And $num3364==$color ) Then 
) MsgBox(0,"Second Number is", 3, 6) ElseIf $num24209==$color Then
  MsgBox(0,"Second Number is", 4  ElseIf $num25203==$color Then
  MsgBox(0,"Second Number is", 5, 6)
  ElseIf $num26206==$color Then
  MsgBox(0,"Second Number is", 6, 6)
   ElseIf $num27411==$color Then
  MsgBox(0,"Second Number is", 7, 6)
 ElseIf ($num28205==$color and $num3836==$color and $num3846==$color) Then
  MsgBox(0,"Second Number is", 8, 6)
 ElseIf $num29308==$color Then
  MsgBox(0,"Second Number is", 9, 6)
 ElseIf $num20107==$color Then
  MsgBox(0,"Second Number is", 0, 6)
 EndIf

$x=$x1+9
$y=136
 
 $num31204=PixelGetColor($x+2,$y+4)
 $num32112=PixelGetColor($x+1,$y+12)
 $num33405=PixelGetColor($x+4,$y+5)
 $num33603=PixelGetColor($x+6,$y+3)
 $num33604=PixelGetColor($x+6,$y+4)
 $num34209=PixelGetColor($x+2,$y+9)
 $num35203=PixelGetColor($x+2,$y+3)
 $num36206=PixelGetColor($x+2,$y+6)
 $num37411=PixelGetColor($x+4,$y+11)
 $num38205=PixelGetColor($x+2,$y+5)
 $num38306=PixelGetColor($x+3,$y+6)
 $num38406=PixelGetColor($x+4,$y+6)
 $num39308=PixelGetColor($x+3,$y+8)
 $num30107=PixelGetColor($x+1,$y+7)
 ;************************* 
  If $num31204==$color Then
  MsgBox(0,"3ed Number is", 1, 5)
 ElseIf $num32112==$color Then
  MsgBox(0,"3ed Number is", 2, 6)
 ElseIf ($num33405==$color And $num3363==$color And $num3364==$color ) Then 
 MsgBox(0,"3ed Number is", 3, 6)
 ElseIf $num34209==$color Then
  MsgBox(0,"3ed Number is", 4, 6)
  ElseIf $num35203==$color Then
  MsgBox(0,"3ed Number is", 5, 6)
  ElseIf $num36206==$color Then
  MsgBox(0,"3ed Number is", 6, 6)
   ElseIf $num37411==$color Then
  MsgBox(0,"3ed Number is", 7, 6)
 ElseIf ($num38205==$color and $num3836==$color and $num3846==$color) Then
  MsgBox(0,"3ed Number is", 8, ))
 ElseIf $num39308==$color Then
  MsgBox(0,"3ed Number is", 9, ))
 ElseIf $num30107==$color Then
  MsgBox(0,"3ed Number is", 0, 6)
 EndIf
 
$x=$x1+9+9;
$y=136
$num41204=PixelGetColor($x+2,$y+4)
 $num42112=PixelGetColor($x+1,$y+12)
 $num43405=PixelGetColor($x+4,$y+5)
 $num43603=PixelGetColor($x+6,$y+3)
 $num43604=PixelGetColor($x+6,$y+)
 $num44209=PixelGetColor($x+2,$y+9)
 $num45203=PixelGetColor($x+2,$y+3)
 $num46206=PixelGetColor($x+2,$y+6)
 $num47411=PixelGetColor($x+4,$y+11)
 $num48205=PixelGetColor($x+2,$y+5)
 $num48306=PixelGetColor($x+3,$y+6)
 $num48406=PixelGetColor($x+4,$y+6)
 $num49308=PixelGetColor($x+3,$y+8)
 $num40107=PixelGetColor($x+1,$y+7)
 ;************************* 
  If $num41204==$color Then
  MsgBox(0,"4th Number is", 1, 5)
 ElseIf $num42112==$color Then
  MsgBox(0,"4th Number is", 2, 6)
 ElseIf ($num43405==$color And $num4363==$color And $num4364==$color ) Then 
 MsgBox(0,"4th Number is", 3, 6)
 ElseIf $num44209==$color Then
  MsgBox(0,"4th Number is", 4, 6)
  ElseIf $num45203==$color Then
  MsgBox(0,"4th Number is", 5, 6)
  ElseIf $num46206==$color Then
  MsgBox(0,"4th Number is", 6, 6)
   ElseIf $num47411==$color Then
  MsgBox(0,"4th Number is", 7, 6)
 ElseIf ($num48205==$color and $num4836==$color and $num4846==$color) Then
  MsgBox(0,"4th Number is", 8, 6)
 ElseIf $num49308==$color Then
  MsgBox(0,"4th Number is", 9, 6)
 ElseIf $num40107==$color Then
  MsgBox(0,"4th Number is", 0, 6)
 EndIf

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  

×