User Tools

Site Tools


Find Image on Screen Action

The Find Image on Screen Action finds a specified image on the screen in a specified area and stores the image location and fuzziness (left,top,width,height,fuzz) in a Keyboard Maestro Variable.

After finding an image on the second monitor, this Action return data like this: 2060,136,60,56,0

Suppose that the image location is stored in the Variable ImageLoc (set by the user). Then parts of the image data (properties) may be referenced in other actions like Move and Click Mouse using the following notation:

  • ImageLoc.x — Horizontal position of upper left corner.
  • ImageLoc.y — Vertical position of upper left corner.
  • ImageLoc.width — the Width of the match (same as the source image).
  • ImageLoc.height — the Height of the match (same as the source image).
  • ImageLoc.fuzz — the Fuzz of the match.
  • ImageLoc.Midx — Horizontal position of center.
  • ImageLoc.Midy — Vertical position of center.

You can require the match to be unique (so if there are two or more good matches then the action will fail to find the image), or you can accept the best match even if there is more than one.

If this action fails to find the image, the variable will be set to the empty string.

After an Action like this is executed, and an image was found, then the %FoundImage% token (v8+) will return the data of the last found image.

Please note that “ImageLoc” is just an example Variable (which you the use can set), whereas %FoundImage% is a token provided by the Keyboard Maestro Engine.

How To Use

Specifying Fields in Found Image Actions

  • Specify the image to match
  • Specify the amount of fuzziness allowed
    • Because of transparency and anti-aliasing almost all screen matches are fuzzy to some degree.
    • But usually about 20% is a good place to start.
  • Optionally highlight Found Matches
    • This can be helpful in determining the right amount of fuzz to use.
    • It can also show when an image is being found in more than one location.
  • Choose Where to Search for Image
    • All screens.
    • Main screen.
    • Specified screen (counting from the left).
    • Front window.
    • Window with a specified title.
    • Window with a title containing a given string.
    • Window with a title matching a given regular expression.
    • Specified window (counting from the frontmost window).
    • Specified area on the screen.

Search in Specified Area

Remember when specifying the area, as with all numeric fields, the numbers can be calculations including functions, and the fields expand to allow for longer expressions as soon as you type something other than a number, so this allows very precise control of where you can match.

Example: Click on Image in Area Relative to Front Window


See Also





action/Find_Image_on_Screen.txt · Last modified: 2018/01/18 21:55 by JMichaelTX