Find Image in Light and Dark Mode?

Any tips on how to have an image detection macro that works for two images, in the day when OSX is in Light Mode and the other image when OSX is in Dark Mode?

When the system darkens the interface to Dark Mode, the Click Found Image no longer detects them because OSX changed the interface.

Try taking two images in both light and dark mode and telling the macro which one to use with KM9's new DARKMODE() function. As an example, here's one I use myself in conjunction with this Safari extension:

PiP Video.kmmacros (47.6 KB)


Thanks, works great!

1 Like

Very interesting solution... I'll keep it in mind :+1:

Palle GT

1 Like

Just a quick thanks – knew this would be an easy fix if I could find the right formula, and of course found this post right away!


Hello @hello :grinning:, I know @gglick has already given you a solution but for future reference I think you can do this in an even simpler way. Just have two Click at Found image Actions (one for mode each dark/light) and set their Action Gears to not abort the macro or notify on failure. No need for an If Then Else or Switch Case Action. This is an idea I got recently, from downloading one of @Sleepy's Macros.


And this works for lots of Macros where there may be different shadings or forms of the found image - for example if it is active or in greyed out mode or changes in some other way depending on the mode.


Ah, nice and simple solution!
Always appreciated when a macro can be simplified.
Thanks @Zabobon !

1 Like

I recognize that approach, which I used elsewhere. Glad someone is reading my macros. If I ever catalog all my coding tricks, this would definitely be one of them.


While this reduces the complexity of the macro it increases the work done by each execution since it'll always search for both images.

Also this doesn't abort the macro when neither image is found.


Yes, and the most robust Solution is provided by @gglick in post #2.

It is logical that these would be concerns but in practical use they haven't been causing me problems.

  1. The search for the two images happens so fast that it is in effect instant.

  2. If neither image is found instantly, the Macro moves on straight away and if there are no other Actions it terminates (i.e. it doesn't hang around looking for the images).

I would say the biggest argument for using a Switch Case or If Then Action is clarity when looking at the Macro's coding at a later date, especially if the Macro has many Actions. And that is why Post #2 should be regarded as the best solution (especially as it is cleverly checking if the Mac is in Light or Dark mode before it searches for an image).

But for simple "click on an image" and "do one thing" kind of Macros, where the image might change slightly, the above works with no noticeable performance issues. And it is easy to adapt if you discover the image is sometimes in a third slightly different form.

I use it for situations where an item I want to click on (or more usually, click a certain distance from) is sometimes in dark type and sometimes greyed. Adobe palettes are an example where the target image seems to change. The original Macro example that I stole this idea from, used it for Finder headers which again can sometimes be grey or sometimes dark.