OK. This is really weird. I switched to using GDIP. The search call looks like this:
Code: Select all
RET := Gdip_ImageSearch(bmpHaystack,bmpNeedle,LIST, 0,0,hWidth,hHeight)
If I set bmpHaystack with this code:
Code: Select all
send ^{PrintScreen}
bmpHaystack := Gdip_CreateBitmapFromClipboard()
it finds the image successfully. But if I set bmpHaysack with the following code, it fails:
Code: Select all
bmpHaystack := Gdip_BitmapFromScreen()
Here's the complete working code. I'd like to un-comment the commented line, but when I do, the search fails.
Code: Select all
p := Gdip_Startup()
Image = e:\autohotkey\search-images\conference-join.png
bmpNeedle := Gdip_CreateBitmapFromFile(Image)
send ^{PrintScreen}
bmpHaystack := Gdip_CreateBitmapFromClipboard()
;bmpHaystack := Gdip_BitmapFromScreen()
Gdip_GetImageDimensions(bmpHaystack,hWidth,hHeight)
RET := Gdip_ImageSearch(bmpHaystack,bmpNeedle,LIST, 0,0,hWidth,hHeight)
MsgBox, RET is %RET%
Gdip_Shutdown(p)
#include e:\autohotkey\scripts\gdip.ahk
#include e:\autohotkey\scripts\Gdip_ImageSearch.ahk
In this case, 'fails' means 'returns zero instead of 1.'