게임내에서 숫자를 인식하는 소스인데 해석좀 부탁드려요 ㅠㅠ
=====================================================================================
number =
WinGet, hwnd, ID, A
imgDir = %A_ScriptDir%\image_autocheck
detectAuto := CheckAutoDetectWindows(x, y, hwnd, imgDir)
if detectAuto
loop 4
number .= GetAutoNumbers(x, y, hwnd, imgDir)
return
CheckAutoDetectWindows(byref num_x, byref num_y, hwnd, imgDir)
{
상태_오토신고창인식 = 주흔.bmp
global FindImage_area_x
global FindImage_area_y
global FindImage_area_width
global FindImage_area_height
FindImage_area_x := 149
FindImage_area_y := 234
FindImage_area_width := 266
FindImage_area_height := 348
if !FindImageScreen(num_x, num_y, hwnd, 상태_오토신고창인식, 70)
return 0
num_x += -3, num_y += 17
return 1
}
GetAutoNumbers(ByRef num_x, ByRef num_y, hwnd, imgDir)
{
global FindImage_area_x
global FindImage_area_y
global FindImage_area_width
global FindImage_area_height
FindImage_area_x := num_x
FindImage_area_y := num_y
FindImage_area_width := 7
FindImage_area_height := 9
margin = 10
loop 10
{
number := A_index - 1
pre = number_%number%
if FileExist(image := pre ".bmp")
{
if FindImageScreen(x, y, hwnd, image, margin)
{
num_x := x + 8
return number
}
}
else
{
loop 9
{
if !FileExist(image := pre "_" A_index ".bmp")
break
if FindImageScreen(x, y, hwnd, image, margin)
{
num_x := x + 8
return number
}
}
}
}
return
}
FindImageScreens(ByRef foundx,ByRef foundy, handle, image, margin)
{
global FindImage_area_x
global FindImage_area_y
global FindImage_area_width
global FindImage_area_height
IfWinNotExist ahk_id %handle%
{
foundx = -1
foundy = -1
return 0
}
CoordMode, Pixel, Screen
WinGetPos, winx,winy , width,height, ahk_id %handle%
if FindImage_area_x>=0
x := winx + FindImage_area_x
else
x := winx + width + FindImage_area_x
if FindImage_area_y>=0
y := winy + FindImage_area_y
else
y := winy + height + FindImage_area_y
if FindImage_area_width and FindImage_area_width<=width
width := FindImage_area_width
if FindImage_area_height and FindImage_area_height<=height
height := FindImage_area_height
ImageSearch, foundx,foundy , x,y , x+width, y+height , *transED1C24 *%margin% %image%
if ErrorLevel=0
{
foundx := foundx - winx -2.7
foundy := foundy - winy
return 1
}
else
if ErrorLevel=1
foundx = -1
else
{
MsgBox,, Error, %A_ThisFunc%`n`nImageSearch ErrorLevel2 오류
ExitApp
}
foundx = -1
foundy = -1
return 0
}
숫자가 들어있는 창의 위치를 파악하고
왼쪽에서부터 하나씩 숫자를 비교하는 로직이네요.
첫번째 숫자가 있을 범위에서 숫자이미지를 0부터 9까지 쭉 비교해보고
이미지가 발견되면 두번째 숫자를 비교하기 위해 x값을 8 증가시키네요.