Gdip_ImageSearch() not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sh977218
Posts: 1
Joined: 06 Jul 2022, 15:39

Gdip_ImageSearch() not working

Post by sh977218 » 06 Jul 2022, 15:51

Hi, I'm trying to use Gdip_ImageSearch() which I downloaded from https://github.com/MasterFocus/AutoHotkey/blob/master/Functions/Gdip_ImageSearch/Gdip_ImageSearch.ahk to test some image searching feature, basically I manually snapped my screen to saved as invitationFullscreen.png, then inside invitationFullscreen.png I snapped a partial of that image, saved as invitation.png. I expect Gdip_ImageSearch(nvitationFullscreen, nvitationFullscreen) would return something, but all I found is 0.
I attached the code I wrote for this testing. Can someone help me to see what I miss here?
Thanks in advanced!

Code: Select all

#Include Gdip_All.ahk
#Include Gdip_ImageSearch.ahk
^r::
	pToken := Gdip_Startup()
	invitationFile :=  A_ScriptDir . "\invitation.png"
	invitationFullscreenFile :=  A_ScriptDir . "\invitationFullscreen.png"
	invitationImage := Gdip_CreateBitmapFromFile(invitationFile)
	invitationFullscreenImage := Gdip_CreateBitmapFromFile(invitationFullscreenFile)
	compareResult := Gdip_ImageSearch(invitationFullscreenImage,invitationImage,LIST,0,0,0,0,0,0xFFFFFF,1,0)
	MsgBox, % "Returned: " compareResult "`n`n" LIST
return


User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Gdip_ImageSearch() not working

Post by boiler » 06 Jul 2022, 19:15

Works fine for me. Are you sure your invitation image is really in your fullscreen image?

You should add the following lines before your MsgBox line:

Code: Select all

	Gdip_DisposeImage(invitationImage)
	Gdip_DisposeImage(invitationFullscreenImage)
	Gdip_Shutdown(pToken)

Post Reply

Return to “Ask for Help (v1)”