User Tools

Site Tools


action:Find_Image_on_Screen

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
action:Find_Image_on_Screen [2015/07/21 21:08]
peternlewis
action:Find_Image_on_Screen [2018/01/18 21:55]
JMichaelTX ADD header, icon, token, and example screenshot
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.+{{:​condition:​image-icon.png?​nolink|}} 
 +====== ​Find Image on Screen ​Action ======
  
-You specify ​the image to match (usually got with Command-Control-Shift-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// [[:​Actions|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 Keyboard Maestro [[manual:​Variables|Variable]]. 
 + 
 +{{:​action:​find-image-on-screen-km.png?​nolink|}} 
 + 
 +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 [[manual:​Variables|Variable]] `ImageLoc` (set by the user). ​ Then parts of the image data (propertiesmay be referenced in other actions like [[action:​Move_or_Click_Mouse|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. 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.
  
-You can optionally display all the matches on the screen which can be helpful in determining ​the right amount ​of fuzz to use.+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 "​ImageLoc"​ 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:​Execute an AppleScript|Execute an AppleScript]] 
 +* [[action:​Highlight Location|Highlight Location]] 
 +* [[action:​Move or Click Mouse|Move or Click Mouse]] 
 +* [[action:​Write to a File|Write to a File]] 
 +* [[:​Actions|See all Actions]] 
 + 
 +===  Conditions === 
 + 
 +* [[condition:​Found Image|Found Image]] 
 +* [[:​Conditions|See all Conditions]]
  
-In v7.0+, you can search for the image on:+===  Collections ===
  
-all screens. +[[collection:​Found Images|Found Images]] 
-the main screen. +[[:​Collections|See all Collections]]
-* 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.+==== Forum ====
  
-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.+- [[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]]
action/Find_Image_on_Screen.txt · Last modified: 2023/09/15 02:21 by peternlewis