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

I want to create a macro create a gesture which toggles between the 2 frontmost windows laying side by side, either windows from 2 different apps or 2 windows from one app (example: Finder or any other app).
thanks in advance for your time and help

This action should switch to the last called window of the last front app.

It does not do the same as this BTT action


Unfortunately, I cannot answer your other question.

1 Like

thank you very much

@Frankb's covered the first.

For two windows of the same app, the front window will always have an index of 1 while the previously active window will usually have an index of 2. So you should be able to just

image toggle between two windows.


That's interesting, Nige. Can KM also do what the BTT action does? Activate the last window, no matter what app was last in front. So a mix between both actions.

I don't think so. My guess is that BTT is somehow determining if the most recent (relevant) action was an app switch or a window switch and behaving accordingly.

Not a clue how it does that, though!

Perhaps "in the background" these two BTT actions are always active. They can also be used specifically.

@Nige_S @Frankb

Thank you both for your suggestions.

I think that BTT covers all eventualities and is my method of choice. There are a few RARE (I have to weigh my words or @peternlewis will expel me from the KM forum!) situations where I use BTT to trigger actions difficult to implement with KBM or AppleScript, for example to select text (a paragraph, a line), clear all notifications, easily access and item in the context menu, switch windows (same or different apps, as per above). I am sure that there are others.

I am not referring to the many instances where I use BTT to trigger a KBM macro.

I would be interested to know if you both have other examples.

I'm sure @peternlewis is sovereign enough not to exclude anyone talking about the pros and cons of KM and BTT. Both apps are fantastic but work differently. :slightly_smiling_face:

It seems to me that both apps can do 80% of the same thing. Anything with "if then" works easier and better with KM. Also, BTT has had nothing to compare to the great KM palettes. That will change next week. Let's see what BTT's new floating menus can do.

Sometimes it's just a bug or inexplicable errors that force me to switch from KM to BTT or vice versa.


Yes, absolutely and just for the record, I was joking.

1 Like

Ah :joy: irony is not always understood :cold_face:

1 Like

Not a BTT user. I try to run as default a machine as I can, lest I get confused when sitting at another user's -- even my KM use is limited to situations unlikely to crop up elsewhere.

1 Like

I am very surprised that someone as sophisticated as you can function without the vast array of BTT trackpad gestures. HUGE improvement in workflow speed.

KBM is by far my number 1, but I could not do without BTT.

You run of risk a regretting not having started using it earlier it if you have a second look at BTT in the future.

HUGE increase in embarrassment level when I go to another user's machine and something I do all the time on mine just won't work on theirs, and it takes me 5 minutes to realise why...

It's bad enough having deal with customisations they've made, without also having to try and forget mine!

1 Like

That's a very good point. BTT will drive them bananas because with BTT your fingers dance on the trackpad.

Every slight motion of the hand of other non BTT familiar users will trigger the BTT equivalent of KM macros.

1 Like

Wont this work to toggle between the two front windows?


Generally you can also save the name of the front window (FrontWindowName token) and then bring to front the window with that name - it wont always work, there might be multiple windows with the same name for example.

1 Like

I think the action you mentioned toggles between windows of the same app. While the KM action "Activate Last Application" toggles between the last two front windows of two apps.

So it needs two different triggers to perform both actions.

The BTT action "Activate Previous Window" works a bit different. It activates the last front window, regardless of the app.

Personally I never need this.


Thinking about it -- all you'd need to do is log any changes. And when you trigger your macro, if the last change was an app switch then activate window 1 of %LastApplication% otherwise bring to the front window 2 of front app.

Hmmm... I can see that being very useful -- I often want to work between two windows in different apps without bringing all their other windows to the front with ⌘⇥ switching...


Failing at the final hurdle. You can use

image bring only one window to the front but you need to refer to a specific app. What I need to do is refer by variable, eg using the bundle ID.

@peternlewis -- am I missing a trick here?

We can work round the problem for now by using app names and a somewhat clunky Switch/Case -- you'll have to add entries to that for all the apps you want to use this with.

Not extensively tested, so consider this a PoC rather than finished product:

Window Switcher - Switch:Case version.kmmacros (10.8 KB)


1 Like

Maybe it would be useful if the action "Activate last Application" had the option "all windows" or not.

Like this

1 Like

...or if you could reference apps by variable in all similar action options. Was editing my previous post when you suggested this -- see the macro there for my clunky workaround...

1 Like