Find Image not working

I have an if statement that tests to see if an image is visible in the front most window.

When I run this it fails even though the image being looked for was taken directly from the front most window.

The image being looked for was created by:

  1. Command + Control + Shift 4
  2. Drag a bounding box around something inside the window
  3. Return to Keyboard Maestro, and Command + V the small image into the form

What is very odd is that, If I run a screen capture command, then the resulting screen capture is of just the background image and menu bar, and does not include any desktop icons or application windows which are open.

If I instead use a fragment from this screenshot of the background inside the IF statement then KM will find the region and will highlight it.

KM is behaving like all the Desktop icons and open application windows are completely transparent for all screenshot and image search operations.

I have done the following:

  • Confirmed that KM has rights to screen capture: System Preferences --> Security and Privacy --> Privacy tab --> Screen Recording
  • Toggled off & on the screen recording permissions, then restarted KM.

Hey Roy,

  • What version of macOS?
  • What version of Keyboard Maestro?
  • How are you activating your macro?

-Chris

Oh all good questions.

OSX v11.5.2, running on MacBook Pro 16in 2019
Keyboard Maestro v9.2
I'm activating the macro using a hotkey combo Command+T

Here is the entire macro:

Your fuzziness is awfully high. I’m sure I’ve never had mine that high before. Move your slider left and don’t pass the first notch. :flushed:

Yeah I tried that too. I actually tried it on all the notches of fuzziness.

Here's what I'm seeing. I have Google.com site loaded and in the foreground. Just behind it I have the Keyboard Maestro macro and the image fragment of the letter "G" from the Google logo, take from that same page.

I'd expect the macro to evaluate to true, but we can see KM shows the condition is currently false. And running the macro it plays the Basso sound effect.

Hey Roy,

Putting my moderator hat on for a second:

When posting macros to the Keyboard Maestro forum please use these guidelines:

  1. Always post a Macro File.
  2. Always post an image.

This means people won't have to reinvent the wheel to test your macro, and that significantly improves the likelihood that someone will help you.

Folks generally won't download something they haven't eyeballed first, so an image of the macro is crucial.


If you haven't seen these they're worth a moment of your time:

How to Post Your Macro to the Forum

Tip: How Do I Get The Best Answer in the Shortest Time?


--
Take Care,
Chris

(Keyboard Maestro Moderator)

Okay...

  • You're sure the macro is actually running when you hit your hotkey?
  • Have you tested with any apps other than Google Chrome?

Google Chrome has an ongoing bug that prevents accessibility from identifying it's front window.

Found Images Suddenly Broken in Google Chrome - #19 by ccstone

This bug should not affect your version that's looking at the whole screen though.

Big Sur's various Windows-Vista-like levels of transparency may cause issues, so try turning on “Reduce Transparency”:

-Chris

I disabled transparency as recommended. And tried this with other programs. This results in the same problem.

I know the macro is getting triggered because it plays the designated audio sound. If I change what audio sounds should play in the "then" or "else" section of the "if then" block, and trigger the macro then the "if then" block test still resolves to "false" and only the "else" sound plays. Additionally "(currently false)" is visible in the screenshots.

To show the same problem occurs with other non-chrome applications. Here is Apple TV and where the keyboard KM macro is configured to look for the Fraggle Rock image on the top right. I'm including this image because it shows that Apple TV is the front window, and it shows the current macro configuration.

If Then Else Action (v9.2)

If Then Else.kmactions (196 KB)

It's the same problem with Spotify desktop app. Here the macro is configured to look for the play button. Again I'm including this image to show that Spotify is the foreground application.

If Then Else Action (v9.2)

If Then Else.kmactions (13 KB)

Here is Apple Music program, with the KM macro configured to look for the red "Play" button in the middle of the screen (not the foreground application). Again, including this image to show the what is visible on screen when the macro is triggered.

If Then Else Action (v9.2)

If Then Else.kmactions (27 KB)

The KM macro was configured for "all screens" plural, but I never have an external screen connected to this MacBook Pro, so it only ever has its internal monitor.

I do recognize that many of these applications already have keyboard shortcuts to activate the play button. I'm only using these applications and the play button here to demonstrate the problem. My actual use case for this function is more complex.

Did you ever get a reply or sort this out? I can't get Found Image to work on my computer at all.

Check permissions for both KM and the KM engine.
If needed, delete and re-add both.