If screen contains image / Move and Click found image

I have a case where an image that was just found in an IF isn't found in a subsequent 'Move and Click at (0,0) from the Center of the Found Image' action.

Basically I'll ask if the screen contains an image. If it does then I try to click the image, but sometimes the image can't be found. This is odd because KM just found the image in its last command.

I'm doing it like this:

Best guess for the issue might have something to do with references sticking around when an Action or an image is copy/pasted.

End goal:
Extra keyboard shortcuts for the Notes application. I want to be able to change notes up or down without having to click in the notes panel.

Then I want to do the same thing for the folder panel (not sure if this is shown by default).

Here's an image of the Notes applications left 2 panes (content grayed out for privacy):

I want to be able to navigate up and down where the red arrows are - without having to click in their respective panes first.

There are no menu options to do this so the only way I can think of is via images. If you have another way then I'd love to hear it.

Why this way?
So why not just click on the found image without an IF? The reason is that there are many possible images, depending on what pane is currently selected or which window is in focus.

I could use the 'if any of the following are true' with multiple images, but then I wouldn't know which one to click on inside the THEN.

So I go with simple IF/ELSE - If first image is not found then look for the second image, then the third and so on.

By chaining IF/ELSEs it makes it as efficient as possible (that I know of).

Hey Gregory,

I conjecture that you have the Keyboard Maestro editor window open when you’re testing your script.

The image you’re looking for is also in that window, so this can bollix up the works.

HIDE the Keyboard Maestro editor with Cmd-H before testing.

If that doesn’t help please report back.


The first test allows the image to be non-unique, whereas the Move & Click action requires a unique match of the image.

You could do something like:

  • Find Image on Screen to variable “Where”
  • If variable Where is not empty
    • Move & Click at Where.MidX,Where.MidY

Thanks Peter. That was one ‘find image’ I didn’t know about.

So use ‘Move and Click at (0,0) from the Absolute Position’ with those variable properties?

How would this work for multiple screens?

For Absolute Position, 0,0 is the top left of the main screen (the one with the menu bar in the Displays Arrange settings - it is less obvious now that the menu bar actually appears on all monitors).

Similarly, Find Image and everywhere else in Keyboard Maestro uses absolute coordinates for things like mouse / windows / etc positions

I get the concept but more than one thing is likely wrong with my implementation.

It fails to read the variable in 'Use Variable ‘NotesNavFoundImage’ to Set the Mouse Location'.

The first suggestion I have is to always limit a "Find Image" action to the smallest area you can. My default is "the front window".

Here is a test macro that works for me, to click on the KM logo in the upper left corner of this web page. Triggering the macro should result in the web page changing to the default KM Forum page.

##Macro Library   Click Mouse at @Image IF Found.

<a class="attachment" href="/uploads/default/original/2X/f/f82ac878b7789fb656407854b994b7d941c11c2e.kmmacros">Click Mouse at @Image IF Found..kmmacros</a> (17 KB)



1. Change the Image in the "Find Image on Screen" to be your target image.
2. Adjust the search fuzziness on this Action as needed.


<img src="/uploads/default/original/2X/f/fafed0f3e628fb59c07bbc57503b0c58604237d6.png" width="478" height="867">

You cannot use the results of Find Image (which is 5 numbers (x,y,width,height,fuzz)) in a Use Variable action because it does not have the right number of entries (two numbers x,y). You can use the Move and Click action to just move the mouse like you use it in the next action.

The Move and Click action is wrong because you are moving relative to the current mouse location, the results of Find Image are in absolute coordinates.

NotesNavFoundImage.MidX will be the absolute coordinates (relative to the left edge of the main screen) of the middle of the found image.