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!

best

Z

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.

-Chris

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

|w1|w2|w3|w4|

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

Does that make sense :D?

thx alot

Z

Hey Z,

Well...

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.

-Chris

thx!

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

http://www.hammerspoon.org/docs/hs.window.html#close

I wonder if one could emulate that in KM?

best

Z

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.

-Chris


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

thx alot!

ill try your script :smiley:
best

Z