AutoItSetOption ( "PixelCoordMode" , 2)
AutoItSetOption ( "MouseCoordMode" , 2)
Global $dig_pos[4][2]
$dig_pos[0][0] = 69
$dig_pos[0][1] = 38
$dig_pos[1][0] = $dig_pos[0][0] + 8
$dig_pos[1][1] = $dig_pos[0][1]
$dig_pos[2][0] = $dig_pos[0][0] + 16
$dig_pos[2][1] = $dig_pos[0][1]
$dig_pos[3][0] = $dig_pos[0][0] + 24
$dig_pos[3][1] = $dig_pos[0][1]
Sleep(4000)
WinActivate ("Lineage II")
sleep(1000)
$begin = TimerInit()
$ocr = _OCR()
$dif = TimerDiff($begin)
$dif = $dif / 1000
MsgBox (0, "", "Число: "&$ocr&@CRLF&"Время: "&$dif&" сек.")
Func _OCR()
Local $result = ""
$result &= Recognize($dig_pos[0][0], $dig_pos[0][1])
$result &= Recognize($dig_pos[1][0], $dig_pos[1][1])
$result &= Recognize($dig_pos[2][0], $dig_pos[2][1])
$result &= Recognize($dig_pos[3][0], $dig_pos[3][1])
Return $result
EndFunc
Func Recognize($startposX, $startposY)
Local $x = $startposX, $y = $startposY
$dig_exists = PixelGetColor ($x+2, $y+7)
$dig_exists = Hex($dig_exists, 6)
$dig_exists = TrimColor($dig_exists)
If $dig_exists < 100 Then Return ""
Local $colors[17]
$colors[0] = Hex(PixelGetColor ($x-1, $y+5), 6)
$colors[1] = Hex(PixelGetColor ($x, $y), 6)
$colors[2] = Hex(PixelGetColor ($x, $y+1), 6)
$colors[3] = Hex(PixelGetColor ($x, $y+2), 6)
$colors[4] = Hex(PixelGetColor ($x, $y+3), 6)
$colors[5] = Hex(PixelGetColor ($x, $y+5), 6)
$colors[6] = Hex(PixelGetColor ($x, $y+6), 6)
$colors[7] = Hex(PixelGetColor ($x, $y+7), 6)
$colors[8] = Hex(PixelGetColor ($x+1, $y+3), 6)
$colors[9] = Hex(PixelGetColor ($x+2, $y+1), 6)
$colors[10] = Hex(PixelGetColor ($x+2, $y+2), 6)
$colors[11] = Hex(PixelGetColor ($x+2, $y+4), 6)
$colors[12] = Hex(PixelGetColor ($x+2, $y+6), 6)
$colors[13] = Hex(PixelGetColor ($x+3, $y+5), 6)
$colors[14] = Hex(PixelGetColor ($x+4, $y+2), 6)
$colors[15] = Hex(PixelGetColor ($x+4, $y+7), 6)
$colors[16] = Hex(PixelGetColor ($x+5, $y+3), 6)
For $i = 0 to 16
$colors[$i] = TrimColor($colors[$i])
Next
If $colors[16] >= 130 Then Return "0"
If $colors[0] >= 130 Then Return "4"
If $colors[9] >= 130 And $colors[10] >= 130 Then Return "1"
If $colors[7] >= 130 And $colors[15] >= 130 Then Return "2"
If $colors[2] >= 130 And $colors[4] < 100 And $colors[6] >= 130 Then Return "3"
If $colors[4] >= 130 And $colors[8] >= 130 Then Return "5"
If $colors[6] >= 130 And $colors[9] >= 130 Then Return "6"
If $colors[1] >= 130 And $colors[12] >= 130 Then Return "7"
If $colors[3] >= 130 And $colors[5] >= 130 And $colors[11] >= 130 Then Return "8"
If $colors[3] >= 130 And $colors[13] >= 130 And $colors[14] >= 130 Then Return "9"
Return ""
EndFunc
Func TrimColor($TargetTrim)
Dim $a, $as, $as1, $as2, $a_fin
$a = $TargetTrim
$a_fin = (Dec(StringTrimRight($a, 4)) + Dec(StringTrimLeft(StringTrimRight($a, 2), 2)) + Dec(StringTrimLeft($a, 4)))/3
$TargetTrim = Round($a_fin, 0)
Return $TargetTrim
EndFunc