NumResults := Gdip_ImageSearch(pHaystack, pNeedle, ImageCoords, aX-2, aY-2, , , , , , 0)
However, this returns zero results:
NumResults := Gdip_ImageSearch(pHaystack, pNeedle, ImageCoords, aX-2, aY-2, aX + 200, aY + 200, , , , 0)
Despite the fact that per an earlier search I did, the first result is at aX, aY. I've tested this with a variety of circumstances and come to the inescapable conclusion that ANY time OuterX2 or OuterY2 is non-zero, Gdip_ImageSearch returns zero results, regardless of the haystack or needle.
Has anyone else experienced this bug? Do you have any idea how to fix it?
Here is my full code, in case it helps, with the non-working image search commented out.
Code: Select all
if !pToken := Gdip_Startup() ; Start GDI+ for advanced image handling
{
MsgBox, 48, % "GDI+ error!", % "GDI+ failed to start. Please ensure you have gdiplus on your system!"
return
}
AnchorPath := A_WorkingDir . "\Utils\Anchor.png"
pNeedle := Gdip_CreateBitmapFromFile(AnchorPath)
pHwnd := WinExist("A")
pHaystack := Gdip_BitmapFromHWND(pHwnd) ; Create the haystack from the active window
Gdip_ImageSearch(pHaystack, pNeedle, ImageCoords)
Pos := InStr(ImageCoords, ",") ; Split the coordinates into X and Y
aX := SubStr(ImageCoords, 1, Pos-1)
aY := SubStr(ImageCoords, Pos+1)
;NumResults := Gdip_ImageSearch(pHaystack, pNeedle, ImageCoords, aX-2, aY-2, aX + 200, aY + 200, , , , 0)
NumResults := Gdip_ImageSearch(pHaystack, pNeedle, ImageCoords, aX-2, aY-10, , , , , , 0)
Gdip_DisposeImage(pNeedle)
Gdip_DisposeImage(pHaystack)
Gdip_Shutdown(pToken)
return NumResults