Image Search

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Image Search

17 Jun 2021, 13:42

I'm trying to do an image search and I'm not having success

the image has a 20x20 pixel aspect ratio

Does anyone know any image search code that works?

Code: Select all

#SingleInstance Force
 
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
 
1::
 Loop
{
ImageSearch,,, 0, 0, 1366, 768, C:\Users\Hernest\Desktop\name images\UtamoBroken.png
    if (ErrorLevel = 0)
    {
        MouseMove, %x%, %y%, lower
        break
    }
}
 
return

I'm trying to do the search with the code above, but not if the code is correct
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Image Search

17 Jun 2021, 13:53

ur imgsearch call doesn't declare any output variables(unless thats by design)

x and y are undefined blank variables. mousemove doesnt have any "lower" options. ur mousemove isnt doing anything
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: Image Search

17 Jun 2021, 14:31

could you help me with an image search code?
I would like to get the image area I am looking for when I press the "1" key
I'm young and I don't know how to create something like that
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Image Search

17 Jun 2021, 14:42

I would like to get the image area I am looking for when I press the "1" key
seems to me(based on ur original code), u wanted to check if an image is being displayed anywhere on-screen(the entire screen), and if it is, move the mouse some place(who knows where, since x/y havent been specified)
now ure saying something different entirely, that u want "to get the image area(what does that even mean?) ure looking for(how should i know what it is ure looking for?)"
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: Image Search

17 Jun 2021, 15:14

yes I would like to show a message box with the area where the image was found.
example :
Message Box :
image was found at x=90 y=240 x1=250 y1=400


if the image is not found, a box message appears warning that it was not found.

I don't know how to do this, so I need help to start learning a little bit how to make my projects with images


NOTE: I put the moving mouse part totally wrong because I'm a layman and I'm still learning, it can be removed as it's really useless
User avatar
boiler
Posts: 16985
Joined: 21 Dec 2014, 02:44

Re: Image Search

17 Jun 2021, 15:53

ImageSearch does not return an area that the found image covers. It returns the coordinates of the upper-left corner. You could calculate the lower-right corner if you know the size or use one of the various methods that have been posted on the forum for determining the size of an image. Here is how you would report the location of where it was found both in a MsgBox and by moving the mouse to that location:

Code: Select all

#SingleInstance Force
 
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
 
1::
 Loop
{
ImageSearch, x, y, 0, 0, 1366, 768, C:\Users\Hernest\Desktop\name images\UtamoBroken.png
    if (ErrorLevel = 0)
    {
        MsgBox, % "image was found at x=" x " y=" y
        MouseMove, x, y
        break
    }
}
 
return

If you want to search once and report whether it was found or not, like you mentioned in your last post:

Code: Select all

#SingleInstance Force
 
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
 
1::
ImageSearch, x, y, 0, 0, 1366, 768, C:\Users\Hernest\Desktop\name images\UtamoBroken.png
if (ErrorLevel = 0)
{
    MsgBox, % "image was found at x=" x " y=" y
    MouseMove, x, y
}
else
    MsgBox, image was not found
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, teadrinker and 99 guests