Code: Select all
#Include Gdip_All.ahk
#Include Gdip_ImageSearch.ahk
bStat := GDI_ImageSearch("Target Client", OutX, OutY, 0, 0, 1366, 768, 0, 1, "Enemy.png", OutError)
if(bStat)
{
msgbox, % "Found! -> X: " OutX " Y: " OutY
}
else
{
msgbox, Not Found!
}
GDI_ImageSearch(WindowTitle="", byref OutputVarX=0, byref OutputVarY=0, X1=0, Y1=0, X2=0, Y2=0, Variation=30, Direct=1, ImageFile="", byref Error="")
{
WinGet, hwnd, ID, %WindowTitle%
pToken := Gdip_Startup()
pBitmapHayStack := Gdip_BitmapFromhwnd(hwnd)
if(pBitmapHayStack = 0)
{
Error := "Failed to retrieve target window information!"
return false
}
pBitmapNeedle := Gdip_CreateBitmapFromFile(ImageFile)
if(pBitmapNeedle = 0)
{
Error := "Could not load image file!"
return false
}
sleep, 10
if(Gdip_ImageSearch(pBitmapHayStack, pBitmapNeedle, list, X1, Y1, X2, Y2, Variation, 0x000000, Direct, 1) )
{
StringSplit, LISTArray, LIST, `,
OutputVarX := LISTArray1
OutputVarY := LISTArray2
Gdip_DisposeImage(pBitmapHayStack)
Gdip_DisposeImage(pBitmapNeedle)
Gdip_Shutdown(pToken)
return true
}
else
{
Gdip_DisposeImage(pBitmapHayStack)
Gdip_DisposeImage(pBitmapNeedle)
Gdip_Shutdown(pToken)
Error := "No image found!"
return false
}
}