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?
Gdip ImageSearch
Re: Gdip ImageSearch
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.
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.
-
- Posts: 343
- Joined: 08 Jun 2019, 17:36
Re: Gdip ImageSearch
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.
-
- Posts: 343
- Joined: 08 Jun 2019, 17:36
Re: Gdip ImageSearch
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)
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)
}
Re: Gdip ImageSearch
imageSearch2 works with variation (slower).what is the difference between imageSearch1 and ImageSearch2?