Is there a KM action equivalent to BTT "switch to previous window"?

So your macro should toggle between the first window of app A and the first window of app B without showing the other windows of these apps?

Sorry, unfortunately not, not here. :man_shrugging: :slightly_smiling_face:

Ah, sorry, correction. Of course it only works with the apps that are built into the macro. :joy:


Apologies if this has already been shared, but in most apps, command-` (the tilde key) will rotate between windows of the same app. So this is an easy partial solution if you are only toggling between windows of the same app.


Does this not do what the Switch actions are doing? Briefly tested (had to change the hot key to run it here).

Window Switcher - Switch/Case version Macro (v10.2)

Window Switcher - Switch-Case version.kmmacros (5.9 KB)

Keyboard Maestro Export

1 Like

And ⌘⇥ will let you toggle apps, but brings all the app's windows to the front.

Unfortunately, "Activate Last Application" brings all the last app's windows to the front.

We're trying to replicate a BTT command which allows you to toggle between the two frontmost windows, regardless of whether they are of the same or different apps, without raising any other windows, and using a single hot key for both one-app and two-app situations so we don't have to think.

Sample use case: I've always got 2 or more FileMaker windows open, and a whole bunch of Safari windows. When on-boarding new staff the workflow includes repeatedly swapping between one of those FileMaker windows and one of those Safari windows. The macro lets me do that, always keeping both those windows in front of everything else.

1 Like

@Nige_S Your macro works perfectly. But you have to know how to build it first, then you have to build it and finally add all the desired apps.

It's all doable, but not suitable for beginners.

@peternlewis liked this

Maybe this means he wants to implement this in the future.

If you are serious about the constantly recurring question: How to make KM easier for beginners? Then this would be a small start. One click, instead of a macro with 50 parts. :wink:


Totally agree. But sometimes you have to work with what you've got -- while asking for something better. Whether that be "Activate Last Application... but only window x", adding the ability to use variables/tokens in all actions where you can pick an app, both of those, or something better... Who knows?

1 Like

Ah ha. Thanks for clarifying. I'm mostly a one-window guy so didn't notice the limitation.


Adding an option for every location that references an application to allow a variable selection of the application would be an awful lot of UI, enough to make it virtually impractical.

For activating an application, the Use Variable action has an option to activate an application by name.


Not sure I understand. It's about activating the "last front app" and from this app only the "last front window". The last front app can't be activated by name because it can be any app. If I want to activate an app by name, there are many possibilities.

1 Like

You can monitor app switches and save the last app's name in a global variable – then you can reactivate that app by name.


I knew I was missing something. And that action only brings the frontmost window of the app to the front, leaving any others behind the previously frontmost window. So:

Front Two Windows Switch (same or different apps).kmmacros (4.9 KB)


Thanks @peternlewis! Awesome as always.


Here's another spin that's really simple, but does have a possible pitfall: if app A has two or more windows and is frontmost and app B is side-by-side, the macro will always favor the second window of the frontmost application (even if the focus has most recently alternated between app B and app A.)

I can live with this shortcoming, because I always use a quick tap of ⌘-Tab to toggle between two apps.

Download: Swap Between Front Two Windows or Applications.kmmacros (11 KB)


  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.3.1 (22E772610a)
  • Keyboard Maestro v10.2

1 Like

thank you very much @_jims

1 Like

Which, unfortunately, brings all the windows of the newly-activated app to the front, potentially covering the window you've toggled from.

I'm starting to think I'm the only person who uses multiple windows in multiple apps and wants to toggle between two windows of two apps and keep both visible!


Hi, @Nige_S; good point, this could be problematic if one is using a single Mission Control Desktop Space. (I'm an oddball and use all 16.)

App windows open on other Desktop Space or app windows that are minimized are not brought up and, moreover, are not in the rotation when using the macro I shared.

You could move the subset of windows of interest to a separate Desktop Space and do just that without disrupting the other app windows.

Admittedly, Desktop Spaces are a double-edge sword, but since the majority of my work is now on a MacBook Pro, I'm all in. Maybe you've seen this: Desktop Spaces • Macros to Improve Navigation and Window Management

1 Like

Never use them. Partly because of the incomplete implementation, partly because I've never spent enough time trying them, partly because I don't compartmentalise in that way, partly because maintaining the same same Spaces setup across multiple machines is a pain.

But mainly, I suspect, because my primary machines have been 27-inch iMacs for the last dozen years!

There's also the fact that every user of Spaces that I go to help at work is clueless, and spends far longer trying to find the Space they want to use than they would ever spend simply bringing the right windows to the front of a single space :wink: I daresay that seeing a pro like you using them properly would change my opinion a lot!


Done for the next version.

So you made an exception?

No. That comment is about the ability to use a variable in place of a selected application in a popup menu selection.

I am referring to the options to the Activate Last Application action for All Windows / Reopen Windows.

Thank you all for figuring this out and creating a macro for it. :slight_smile:
I used to use AltTab, a free app that does the same thing. But I will be using this macro moving forward.