#NoEnv
#Persistent
#SingleInstance, force
SendMode Input
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, ToolTip, Screen
SetWorkingDir %A_ScriptDir%
SetBatchLines,-1
ListLines, Off
SetTitleMatchMode, Fast
SysGet, WindowCaptionHeight, 4
SysGet, WindowBorderWidth, 32
SysGet, WindowBorderHeight, 33
CheckImage(img, seconds=0, ByRef imgX="", ByRef imgY="", fromX=0, fromY=0, toX=0, toY=0) {
global ActiveID, DebugMode
Sleep, 10
If ( ActiveID)
WinGetPos, winX, winY, winW, winH, % ActiveID
Else
winX := 0, winY := 0, winW := A_ScreenWidth, winH := A_ScreenHeight
sleepTime := 100
times := seconds * (1000 / sleepTime)
If ( times=0)
times := 1
x := winX, y := winY, w := winX+winW, h := winY+winH
If (fromX && fromY && toX && toY)
{
w := x+toX, h := y+toY, x := x+fromX, y := y+fromY
If ( DebugMode = 1)
{
ToolTip, 범위시작, x, y, 11
ToolTip, 범위끝, w, h, 12
}
}
Loop, %times%
{
ImageSearch, oX, oY, x, y, w, h, *50 %A_ScriptDir%\%img%
If ( ErrorLevel = 0)
{
imgX := oX
imgY := oY
If ( DebugMode = 1)
{
ToolTip, %img%, imgX, imgY, 10
}
Return 1
}
Else If ( ErrorLevel = 2)
{
MsgBox, , , 이미지 없음 : %img% , 1
Return -1
}
Sleep, %sleepTime%
}
Return 0
}
ClickImage(img, seconds=0, fromX=0, fromY=0, toX=0, toY=0) {
Sleep, 10
result := CheckImage( img, seconds, x, y, fromX, fromY, toX, toY)
If (result = 1)
{
global ActiveID, DebugMode, WindowCaptionHeight, WindowBorderWidth, WindowBorderHeight
WinGetPos, winX, winY, winW, winH, % ActiveID
px:=x-winX-WindowBorderWidth
py:=y-winY-WindowBorderHeight-WindowCaptionHeight
p := px|py<<16
If ( DebugMode = 1)
{
ToolTip, 이미지 클릭 %img%, x, y, 10
}
PostMessage, 0x201, 0, %p%, , % ActiveID
PostMessage, 0x202, 0, %p%, , % ActiveID
}
Sleep, 200
Return result
}
q::
ClickImage( "123.bmp")
Return
f12:: exitApp
f11:: Reload
왜 클릭은 안되죠 .. ? 결과 값은 1로 뜨는데 클릭이안되네요 ..