This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
action:Find_Image_on_Screen [2015/07/15 03:09] peternlewis created |
action:Find_Image_on_Screen [2019/07/08 00:26] peternlewis |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | 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. | + | ====== Find Image on Screen Action ====== |
- | You specify the image to match (usually got with a Command-Control-Shift-4 screen capture) and 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. | + | 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 [[manual:Variables|Variable]]. |
- | 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. | + | {{ findimageonscreen.png?nolink&503x201 | Find Image on Screen }} |
- | You can optionally display all the matches on the screen which can be helpful in determining the right amount of fuzz to use. | + | You can specify the image to search based on: |
- | You can search for the image on: | + | * An image pasted in to the action. |
+ | * An image from the System Clipboard, Trigger Clipboard or a Named Clipboard (v9.0+). | ||
+ | * An image loaded from a file (v9.0+). | ||
+ | * An image from elsewhere on the screen (v9.0+). | ||
- | * all screens. | + | You can also specify the fuzz allowed in the match, as well as whether to display the possible matches (generally used for debugging), and whether the image must be unique, or if not, which of the acceptable images to choose (the best, the topmost (v9.0+), leftmost (v9.0+), bottommost (v9.0+), or rightmost (v9.0+)). |
- | * the main screen. | + | |
- | * the specified screen (counting from the left). | + | |
- | * the front window. | + | |
- | * the window with a specified title. | + | |
- | * the window with a title containing a given string. | + | |
- | * the window with a title matching a given regular expression. | + | |
- | * the specified window (counting from the frontmost window). | + | |
- | * a specified area on the screen. | + | |
- | Remember when specifying the area, as with all [numeric fields](:Text_Fields), the numbers can be calculations including [functions](: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. | + | You can search the entire desktop, or you can restrict your search to a specific screen or window, or to a specific area on the screen. |
- | 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. | + | Suppose that the image location is stored in the [[manual:Variables|Variable]] `ImageLocation` (chosen by you in the action). Then parts of the image data (properties) may be referenced in other actions like [[action:Move_or_Click_Mouse|Move and Click Mouse]] using the following notation: |
+ | * ImageLocation.x — Horizontal position of upper left corner. | ||
+ | * ImageLocation.y — Vertical position of upper left corner. | ||
+ | * ImageLocation.width — the Width of the match (same as the source image). | ||
+ | * ImageLocation.height — the Height of the match (same as the source image). | ||
+ | * ImageLocation.fuzz — the Fuzz of the match. | ||
+ | * ImageLocation.MidX — Horizontal position of center. | ||
+ | * ImageLocation.MidY — Vertical position of center. | ||
+ | |||
+ | 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 [[token:FoundImage|%FoundImage%]] token (v8+) will return the data of the last found image. | ||
+ | |||
+ | Please note that "ImageLocation" is just an example Variable (which you the use can set), whereas [[token:FoundImage|%FoundImage%]] is a token provided by the Keyboard Maestro Engine. | ||
+ | |||
+ | ===== How To Use ===== | ||
+ | |||
+ | {{page>::Found_Image#How To Use&noheader&nofooter}} | ||
+ | |||
+ | ===== Example ===== | ||
+ | |||
+ | {{:action:find.image.on.screen2.kmmacros|Find Image on Screen.kmmacros}} | ||
+ | |||
+ | {{:action:find.image.on.screen2.jpg?673&nolink|}} | ||
+ | {{:action:find.image.on.screen3.jpg?659&nolink|}} | ||
+ | |||
+ | ===== See Also ===== | ||
+ | |||
+ | ==== Actions ==== | ||
+ | |||
+ | * [[action:Highlight Location|Highlight Location]] | ||
+ | * [[action:Move or Click Mouse|Move or Click Mouse]] | ||
+ | * [[:Actions|See all Actions]] | ||
+ | |||
+ | ==== Conditions ==== | ||
+ | |||
+ | * [[condition:Found Image|Found Image]] | ||
+ | * [[:Conditions|See all Conditions]] | ||
+ | |||
+ | ==== Collections ==== | ||
+ | |||
+ | * [[collection:Found Images|Found Images]] | ||
+ | * [[:Collections|See all Collections]] | ||
+ | |||
+ | ===== Forum ===== | ||
+ | |||
+ | - [[https://forum.keyboardmaestro.com/t/can-i-zoom-the-picture-i-have-saved-in-click-at-found-image-action/2103/2|Can I zoom the picture I have saved in "Click at found image" action?]] | ||
+ | - [[https://forum.keyboardmaestro.com/t/how-to-search-for-multiple-found-image-actions/3093|How To Search For Multiple "Found Image" Actions]] | ||
+ | - [[https://forum.keyboardmaestro.com/t/find-image-on-screen-using-clipboard-image/3510/4|Find Image on Screen using Clipboard Image?]] | ||
+ | - [[https://forum.keyboardmaestro.com/t/km-cant-see-portion-of-screen-i-just-pasted-into-it/3547/3|KM can't see portion of screen I just pasted into it]] | ||
+ | |||
+ | - [[https://forum.keyboardmaestro.com/search?q=Find%20Image%20on%20Screen|Keyboard Maestro Forum topics about Find Image on Screen]] |