Example:
Code: Select all
image := "C:\Users\User1\AppData\Roaming\Script\Images\X.png"
end := A_TickCount + wait
wait := 603
x1 := 451
y1 := 198
x2 := 772
y2 := 532
If FileExist(image)
img := imgSize(image)
Loop {
sleep, 1
ImageSearch , x, y, x1, y1, x2, y2, % image
} Until !ErrorLevel || A_TickCount > end
If !ErrorLevel {
MouseClick ,, x + img.w / 2, y + img.h / 2
} Else
Return
imgSize(img) {
SplitPath img, fn, dir
objShell := ComObjCreate("Shell.Application")
objFolder := objShell.NameSpace(dir), objFolderItem := objFolder.ParseName(fn)
scale := StrSplit(RegExReplace(objFolder.GetDetailsOf(objFolderItem, 31), ".(.+).", "$1"), " x ")
Return {w: scale.1, h: scale.2}
}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]