Keybind to change window focus left/right etc?

Hi all

first day trying KM (also first week on Mac after 15 years of linux :D) and its blowing my mind :smiley:

im wondering if on top of the great resize, move etc actions one can bind actions to switch window focus going in a specific direction?

So for example i could use win+right to keep moving focus each time from all current on-screen clients going towards the right direction. this would hopefully also work continuing to move across screens as well :slight_smile:

any tips would be greatly appreciated!



Hey Z,

This context isn't entirely clear.

Do you mean a single app's windows – or every windowed-app's windows?

Please be more specific.


hi and thx for the reply!

Sorry for being unclear. Yes i mean moving focus from one single app to another.

So if i had 4 windows open


and i was on W2 the bind to move right would move focus from w2 to w3.

Does that make sense :D?

thx alot


Hey Z,


The macOS doesn't see windows right-to-left, it sees them front-to-back.

But if you really want to get fancy you can calculate window positions and move between them.

Take a look at the available WINDOW functions and various window actions such as the Manipulate a Window action.

You won't find this task easy, but with normal windowed-apps it should be doable.



i found out that in hammerspoon there is in fact a way to move focus right/left/up/down between windows by focusing the nearest possible window

I wonder if one could emulate that in KM?



Hey Z,

Could it be done? Yes, but do you really want to invest the time and effort?

As I said:

Then you have to do the math.

Then you can bring the appropriate window to the front.

Personally I don't want to mess with this using Keyboard Maestro actions, but it should be possible to do so.

I wrote a pretty ugly script using AppleScript with UI-Scripting that works.

I have not cased for windows that are in the same position

The macro works in the frontmost application, so the context must be global.


Front Application -- Change Focus to Nearest Window on the Right v1.00.kmmacros (6.2 KB)

thx alot!

ill try your script :smiley: