User Tools

Site Tools


action:Find_Image_on_Screen

**This is an old revision of the document!**

The Find Image on Screen action finds a specified image on the screen and stores the rectangle containing the match followed by the fuzz of the match (0-100), ie, (left,top,width,height,fuzz), in a variable.

The image location is stored in the variable may be referenced as a structure 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.

This action cannot fail per se, but it can fail to find the image, in which case the variable will be set to the empty string.

How To Use

Specifying Fields in Found Image Actions

  • Specify the image to match
    • Paste an image into the image well
      (Use 4 to Take a screenshot of part of your screen).
    • To view the image in the image well, click on it and press SPACE.
    • You can copy the image from the Image Well.
    • Alternatively (v9.0+), you can get the image to search from the System Clipboard, Trigger Clipboard, a Named Clipboard, a file, or from an image elsewhere on the screen.
  • 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.
  • Unique Menu
    • By default, the image must be unique on the screen so that Keyboard Maestro knows where to click, otherwise the action will fail.
    • Alternatively, you can have Keyboard Maestro click based on the best match, or (v9.0+) click on the topmost, leftmost, bottommost, or rightmost match.
  • Display Checkbox – If checked, it will highlight on the screen all found matches
    • This can be helpful in debugging, like determining the right amount of fuzz to use.
    • It will also show when an image is being found in more than one location.
  • Choose Where to Search for Image
    • You can search in all screens, or on a specific screen.
    • Alternatively, you can search within a specific window.
      • However, the window must be in the frontmost, active, application, in order for it to be seen by this Action.
    • Or you can search within a specific 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.

 Click at Found Image Example

Note that in the above screen shot, the WINDOW(0,Left) function is referring to the frontmost window in the frontmost app. To refer to other windows in the frontmost app, you need to change the index parameter of the WINDOW function.

Example

See Also


Actions

Conditions

Collections

Forum

action/Find_Image_on_Screen.1457812723.txt.gz · Last modified: 2016/03/12 14:58 by AlainLifchitz