Imagesearch not working. Tried everything I can think of?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
malamutus
Posts: 2
Joined: 06 Mar 2021, 12:33

Imagesearch not working. Tried everything I can think of?

Post by malamutus » 06 Mar 2021, 12:44

I am a programmer by trade and just installed this to create some macros.

Right away I realized I will need to search for an image and thought this would be simple.

I have tried everything and just cannot get it to recognize an image.

I do not see many other folks having this issue so I am stumped.

Is there something I am missing? Seems it should be a no-brainer.

I took a screen shot, loaded up Paint, cropped what i wanted (image is the size of an icon), saved and tried image as a jpg, bmp, png and it keeps saying "Image / Pixel Not Found."

I have even tried adjusting the "Variations" way up to 200 and still does not detect this image..

Here is the code snippit. It is basically just using the default code inserted from the macro program.

I don't get why this is not working..

Code: Select all

CoordMode, Pixel, Window
ImageSearch, FoundX, FoundY, 0, 0, 2560, 1440, C:\Users\Chris\Desktop\Pulover's Macro Creator\Images\CNBC bmp.bmp
If ErrorLevel = 0
{
    MsgBox, 49, Continue?, Image / Pixel Found at %FoundX%x%FoundY%.`nPress OK to continue.
    IfMsgBox, Cancel
    	Return
}
If ErrorLevel
{
    MsgBox, 49, Continue?, Image / Pixel Not Found.`nPress OK to continue.
    IfMsgBox, Cancel
    	Return
}
If (ErrorLevel = 0)
{
}
[Mod edit: [code][/code] tags added.]

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

Re: Imagesearch not working. Tried everything I can think of?

Post by boiler » 06 Mar 2021, 13:18

Is your image really in the active window when you run the script? If the active window is below or to the right of where the image is on the screen, then it won’t find it because your script defines the upper-left corner of the search area as the upper-left corner of the active window. If you run the script from the File Explorer, then that would be the active window when it executes.

Try changing the first line from Window to Screen. It seems that you are searching what would be a full screen area anyway. Also, stick to png or bmp files, not jpg because they are lossy.

malamutus
Posts: 2
Joined: 06 Mar 2021, 12:33

Re: Imagesearch not working. Tried everything I can think of?

Post by malamutus » 06 Mar 2021, 15:35

Thanks for the quite reply...

It was actually the desktop i was experimenting with. Capturing a section of the desktop (which included an icon) that i was trying to get a hit on. I may be incorrectly thinking it would treat what is on the desktop (icons) as an "image"?

Let me do some more experimenting on true "images"

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

Re: Imagesearch not working. Tried everything I can think of?

Post by boiler » 06 Mar 2021, 19:04

There’s no reason it wouldn’t find an icon on the desktop as long as it’s visible. It’s still likely that you need to change it to CoordMode, Pixel, Screen instead of Window. Did you try that? Is the icon visible when you run the script?

Seigtros
Posts: 3
Joined: 12 Mar 2021, 09:40

Re: Imagesearch not working. Tried everything I can think of?

Post by Seigtros » 12 Mar 2021, 09:58

I see that this is talking about Pulover's Macro Creator. Which version is it ?

I also encounter same problem on version 5.4.0 where there macro stuck when running an image search. i using .png as the image to search in active window.

im not sure what when wrong since there is no error happen. place msg box inside the "if image found" failed no msg box show up.
i use the same settings like in tutorial video on version 5.3.9 and it work. after update its not working anymore.

i try to revert to version 5.3.9 then try again but weirdly the problem stay. now both version didn't work anymore when do the image search :(

The macro i make just do simple task. if the image found move to a coordinate and click it. if the image not found do nothing (break)

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

Re: Imagesearch not working. Tried everything I can think of?

Post by boiler » 12 Mar 2021, 10:49

Seigtros wrote:
12 Mar 2021, 09:58
I see that this is talking about Pulover's Macro Creator. Which version is it ?
It’s actually about native AutoHotkey code. It appears that the OP’s folder named “Pulover's Macro Creator” contains his image folder, but the script is just AHK. The code discussed in this thread is not dependent on the version of PMC as it runs with AHK, and just about any version of it.

Post Reply

Return to “Ask for Help (v1)”