[오토핫키] 다른 이미지 여러개를 동시에 이미지서치

2024. 10. 1. 08:43오토핫키 중급

 

 

#NoEnv
SetWorkingDir %A_ScriptDir%
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%

; 좌표 모드 설정
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

; 이미지 파일 경로 설정 (스크립트와 같은 위치의 "이미지" 폴더)
imageFolder := A_ScriptDir . "\이미지"
images := []  ; 빈 배열 생성

; 이미지 파일 추가
images.Push("사진1.png")
images.Push("사진2.png")
images.Push("사진3.png")
images.Push("사진4.png")
images.Push("사진5.png")
images.Push("사진6.png")
images.Push("사진7.png")
images.Push("사진8.png")
images.Push("사진9.png")
images.Push("사진10.png")

; 결과를 저장할 변수들
foundImages := []
notFound := []
fileNotFound := []

; 각 이미지를 한 번씩 검색
for index, image in images
{
    imagePath := imageFolder . "\" . image ; 이미지 파일 경로
    
    ; 이미지 파일 존재 여부 확인
    if !FileExist(imagePath)
    {
        fileNotFound.Push(image) ; 존재하지 않는 이미지 추가
        continue ; 다음 이미지로 넘어감
    }

    ; 이미지 검색
    ImageSearch, x, y, 0, 0, A_ScreenWidth, A_ScreenHeight, *100 %imagePath%
    
    if (ErrorLevel = 0)
    {
        foundImages.Push({name: image, x: x, y: y})
    }
    else if (ErrorLevel = 1)
    {
        notFound.Push(image) ; 찾지 못한 이미지 추가
    }
}

; 결과 메시지 생성
resultMsg := ""

; 찾은 이미지 결과
if (foundImages.Length() > 0)
{
    resultMsg .= "찾은 이미지:`n"
    for index, img in foundImages
    {
        resultMsg .= img.name . " (좌표: " . img.x . ", " . img.y . ")`n"
    }
    resultMsg .= "`n"
}

; 존재하지 않는 이미지 결과
if (fileNotFound.Length() > 0)
{
    resultMsg .= "존재하지 않는 이미지 파일:`n"
    for index, img in fileNotFound
    {
        resultMsg .= img . "`n"
    }
    resultMsg .= "`n"
}

; 찾지 못한 이미지 결과
if (notFound.Length() > 0)
{
    resultMsg .= "찾지 못한 이미지:`n"
    for index, img in notFound
    {
        resultMsg .= img . "`n"
    }
}

; 결과 메시지 표시
if (resultMsg != "")
{
    MsgBox, %resultMsg%
}
else
{
    MsgBox, 모든 이미지를 찾았습니다.
}

 

 

동시에 여러가지 다른 이미지 찾기.zip
0.02MB

 

 

[오토핫키] 다른 이미지 여러개를 동시에 이미지서치

 

각각 다른 이미지를 이미지서치 병렬을 통하여 동시에 이미지서치할 수 있다.

 

엄밀히 따지면 동시에는 아니고 하나를 찾고 다음 이미지를 찾는 형식이지만, 속도면에서 동시에라고 할 수 있겠다.

 

 

 

 

 

프로그램 개발 의뢰 및 문의

검은망치 카카오톡오픈프로필 : https://open.kakao.com/o/sDUaoCNg

 

[오토핫키] 검은망치님의 오픈프로필

오토핫키 개발러

open.kakao.com