Gdip ImageSearch

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Gdip ImageSearch

27 Oct 2021, 23:03

Hey guys,
I'm using GDIP imageSearch to build automations for my clients.
however, for every 3 clients that appear, usually 1 has a problem with Gdip ImageSearch.

the Haystack and Needle Bitmap return values correctly.
but GdipImageSearch always returns 0, it doesn't find the image even though it's on the screen.

Has anyone experienced this problem? I can't solve it and I have to use autohotkey's native "ImageSearch" function to work.
Could someone give me ideas of what I can check to know where the error is?
in my situation what would you do to find out what the problem is?


could also explain how the "Trans" in GdipImageSearch works?

NOTE:
the times that GdipImageSearch did not work correctly Windows was 7,8 or 11.
Has anyone tried to use GdipImageSearch on these windows?
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Gdip ImageSearch

27 Oct 2021, 23:54

1) Dont use image search for automation. It is bad practice.
2) Ask lexikos for adding window hwnd parameter to ahk`s imagesearch.
If You fail with those, then You need to understand how algorithm of Gdip ImageSearch works and may be modify c++ code.
https://github.com/MasterFocus/AutoHotkey/blob/912011380caf37a690ff911d9ded388f4ada2f4e/Functions/GDI%2B%20ImageSearch/Gdip_ImageSearch.c
As I remember it does not always correct work with variation = 0, so You can try always search with _ImageSearch2 machine code.
And for testing I recommend You take 1 big picture and search small ones in it.
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: Gdip ImageSearch

28 Oct 2021, 16:29

malcev wrote:
27 Oct 2021, 23:54
As I remember it does not always correct work with variation = 0, so You can try always search with _ImageSearch2 machine code.
what is the difference between imageSearch1 and ImageSearch2?

can I choose a variation on this Gdip MachineCode you sent?
doubledave22
Posts: 343
Joined: 08 Jun 2019, 17:36

Re: Gdip ImageSearch

28 Oct 2021, 17:18

If ahk imagesearch works on the window so should gdip image search. Try to save bitmap to file with Gdip_SaveBitmapToFile and analyze the image to make sure it comes out properly. Some applications and depending on Win7/10 etc the bitmap is just all black so I'd start there. If image looks correct it could be an issue with the haystack as well so you can save that to file too and analyze it.
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: Gdip ImageSearch

28 Oct 2021, 17:49

DELETED
Last edited by ibieel on 28 Oct 2021, 18:58, edited 2 times in total.
doubledave22
Posts: 343
Joined: 08 Jun 2019, 17:36

Re: Gdip ImageSearch

28 Oct 2021, 18:52

Gdip_SaveBitmapToFile is really easy it just saves it to your script directory.

I threw this together for you real fast though (you will need to include standard gdip library)

Code: Select all

^t::
DisplayBitmap(Winexist("A"))
return

DisplayBitmap(hwnd)
{
	Gui, 99:+LastFoundExist
	IfWinExist
		gui, 99: Destroy
	
	pBitmap := Gdip_BitmapFromHWND(hwnd)
	hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
	
	Gui,99: Add, Picture,0xE, HBITMAP:%hBitmap%
	Gui,99: Show

	DeleteObject(hBitmap)
	Gdip_DisposeImage(pBitmap)
}
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Gdip ImageSearch

28 Oct 2021, 20:34

what is the difference between imageSearch1 and ImageSearch2?
imageSearch2 works with variation (slower).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: OrangeCat and 243 guests