Don't work ImageSearch

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
aleks
Posts: 4
Joined: 28 May 2023, 06:26

Don't work ImageSearch

28 May 2023, 06:49

Hello.

I use the following code

Code: Select all

^F5:: {  ; CTRL-F5 = Search for image
CoordMode 'Pixel'
CoordMode 'Mouse'

MsgBox ImageSearch(&x, &y, 0, 0, A_ScreenWidth, A_ScreenHeight, pic2  := "C:\Users\Administrator.AXAPTA2012\Documents\AutoHotkey\sword_magenta.png")
}
I use the picture from one program, everything works.
If I run another copy of the same program, the code doesn't work. I tried this code the next day, the picture is not in both copies of the program. Explain what the problem is and how to solve it
Last edited by gregster on 28 May 2023, 06:51, edited 1 time in total.
Reason: Added code tags.
User avatar
boiler
Posts: 16985
Joined: 21 Dec 2014, 02:44

Re: Don't work ImageSearch

28 May 2023, 07:15

It could be that the image you are trying to find looks the same generally but is rendered differently. Capture a screen shot of the one you are trying to find and zoom in on it and your reference image and look for differences at the pixel level.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Don't work ImageSearch

28 May 2023, 07:16

the problem is in ur "program" (game really, lets not kid ourselves)

maybe ure doing something with it that changes the sword's graphic(eg resizing the window, this changing the target image's dimensions)
or maybe uve captured an antialiased image that would change every time its placed somewhere else
or maybe uve captured a semitransparent image which would exhibit the same problem
or maybe the game randomizes the pixels of all graphics subtly every time u start it anew(although thats not an anticheat measure ive ever seen anywhere)
aleks
Posts: 4
Joined: 28 May 2023, 06:26

Re: Don't work ImageSearch

01 Jun 2023, 06:48

Hello
Yes it is a game. But how to find similar pictures if they differ slightly and is it possible to indicate the percentage of discrepancy between pictures, when we can assume that the pictures are similar
User avatar
boiler
Posts: 16985
Joined: 21 Dec 2014, 02:44

Re: Don't work ImageSearch

01 Jun 2023, 08:09

What you might think are slight differences are so different on a pixel-by-pixel basis that ImageSearch may have no possibility of finding it no matter how much variation you allow. Remember, this isn't a human brain looking at an image and recognizing it as another. It's simply doing a comparison of a set of pixels. The only way to tell is to capture an image and see how different it looks from your reference image when you zoom in on both and compare them at a pixel level.

It could also be that you are capturing a piece of the background in your reference image that changes in other instances, and if that's the main thing that's changing, it can be handled by using the *Trans option of ImageSearch by modifying your reference image to indicate which pixels are to be ignored.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: TomDonovan, william_ahk and 74 guests