Any Window

The If/Then Any Window condition is something that I thought I understood. Apparently, I don't.

I have 4 Finder Windows open on my Desktop. Applications, Desktop (⁨Desktop⁩ — Local), Documents (⁨Documents⁩ — Local) and Downloads.

I'd like for the following to be true:

Any title window contains: Desktop, Documents and Downloads but not Applications.

I'm losing it or maybe I'm looking at it too long.

Can someone explain to me why all of these are true? Shouldn't only the last one be true?

Here is the macro:
Any Window.kmmacros (10.8 KB)

Macro Image

Please correct me because I'm clearly not getting it today (or yesterday).

Thank you!


I had similar puzzling results until I ran the macro in the same Desktop space as the open folders.

@mrpasini - I'm still getting same puzzling results. KM is just clowning me at this point.

I run a hotkey, from my desktop and still gives me the wrong result. It shows true in the Editor also.

With the 4 windows open, on my desktop, this should not be true and should give me the otherwise "Works as advertised" display text.:

It's either:

A) I don't have the slightest idea how this works.
B) A bug

It's most likely A.


I had different windows but some open and some closed. The macro only looks at the active Space (not open Finder windows on other Spaces). But this was reliable:

So I'd suggest stripping your sample code down to the two cases (does/does not) and using simpler folder names to get the pot boiling. Then add a new condition with a real name to see if the behavior changes.

Thanks for your efforts. The pots not boiling on this one. Even with 2 windows open on the same space, I'm not getting the desired results with the does contain/does not contain/matches/does not match results. Something is very off - Either with me or with Keyboard Maestro. I'll have to ask Batman on this one - @peternlewis?

Thanks @mrpasini !

Yeah, further testing here shows some problems with the 'does not' condition of Any_Window, whether contains or match.

In your macro:


This will be true if you have The “Desktop — Local”, “Downloads” and “Documents — Local” windows open.

The last condition:


is never going to be relevant.

Because if the “Desktop — Local” windows exists, then a window that is not Applications exists so the last condition will be true.

It is not an All windows of the Finder are not “Applications” test.

It is a Any window of the Finder is not “Applications” test.

To do what you want you need to use two Ifs, something like:

  • If none of the following are true
    • Any window of the Finder is “Applications”
      • If all of the following are true

This right here! Got it. I knew it was my incorrect logic. Thank you for explaining this and providing a solution. I will practice this further.


1 Like