MACROS: Cycling Window Manager

keyboard-maestro-cycling-window-manager

A cycling window manager partially inspired by Raycast, but with extra unique features such as undo and compound hotkeys.

Why use this over the new window management features in MacOS 15 Sequoia?

  1. Cycling behavior gives quick access to more window positions without having to remember as many hotkeys
  2. Compound hotkeys provide an intuitive visual/spatial set of key combinations that are easy to remeber
  3. Undo functionality

β€”Cycling Window Managerβ€”

Written by @gaufde

β€”Featuresβ€”

The point of this macro group is to make it easy to size and move window on multiple screens.

These macros support:

  1. Any number of monitors/screens
  2. Move the front window to any half of the screen with a hotkey command
  3. Move the front window to any quarter of the screen, or fill the screen with a compound hotkey command (similar to the WinMover macros by @cfriend)
  4. Move the front window to any third of the screen by repeatedly cycling the hotkey commands (similar to how Raycast does it)
  5. Move the front window to the center of the screen
  6. Move the front window to the center of the screen without resizing
  7. Move the front window to the previous size and position to β€œundo” a move.
  8. Throw the front window to the next/previous screen (maintaining relative size and position)

β€”Requirementsβ€”

These macros were written and tested in KM 11.0.3 on MacOS 13.7.

β€”Example Usageβ€”

βŒƒβŒ₯βŒ˜β† = left column (first cycle)
βŒƒβŒ₯βŒ˜β† = left third (second cycle)
βŒƒβŒ₯βŒ˜β† = left two-thirds (third cycle)
βŒƒβŒ₯βŒ˜β† = middle third (fourth cycle)

Note: Similar behavior is available for β†’,↓, and ↑. Also, despite the animation of the window motion being slower in KM 11.0.2+, I have put work into making sure that the cycling can handle fast inputs. Simply count the number of key-presses and the window should ultimately end up in the correct position!

βŒƒβŒ₯⌘. = Center window on current screen without resizing

βŒƒβŒ₯⌘ + / = center half size (first cycle)
βŒƒβŒ₯⌘/ = center 5/8 size (second cycle)
βŒƒβŒ₯⌘/ = center 3/4 size (third cycle)
βŒƒβŒ₯⌘/ = full screen (fourth cycle)

βŒƒβŒ₯βŒ˜β†β†‘ = top left quadrant of the screen

Note: similar behavior is available for ↑→,←↓, and ↓→.

βŒƒβŒ₯βŒ˜β†β†’ = full screen
βŒƒβŒ₯βŒ˜β†“β†‘ = full screen

Note: these compound hotkeys are most reliable if you hold the keys down for just a moment longer than you would a normal press.

βŒƒβŒ₯⌘Z = cycle through the previous window frames for the current window.

βŒƒβŒ₯← = Throw window to previous screen
βŒƒβŒ₯β†’ = Throw window to next screen

β€”Installationβ€”

Download the .kmmacros file and double click it to install in Keyboard Maestro. The macro group will be disabled by default, so right click and choose enable. That’s it, all the hotkeys should now work!

β€”Parametersβ€”

You can adjust the timeout before the cycling resets in the CWM-SUB: Init macro.

If you want, you can remove the animation delay that KM added in 11.0.2. Simply run the CWM-HELPER: Set WindowSetFrameAnimationTime macro using the β€œTry” button in the KM GUI. If you have issues with windows moving unreliably, then use the CWM-HELPER: Reset WindowSetFrameAnimationTime macro to revert back to the default settings.

β€”Extendingβ€”

It should be relatively easy to extend these macros if you want to customize them or add functionality.

The existing macros should serve as a guide. Duplicate the one most similar to what you want and edit it from there.

That said, here are a couple of important guidelines:

  1. Use your own window_cycle_namespace for new functionality. The namespaces currently used are up, down, left, right, center, undo, and reset. You will choose a namespace when calling CWM-SUB: Calculate cycling index, or you can write to the dictionary directly. If you need to force the cycle to reset, then set window_cycle_namespace in the dictionary to reset directly.

  2. When using CWM-SUB: Move window to position, the last parameter allows you to choose between passing coefficients only, or passing the values directly. Coefficients are easiest when working with fractions of the screen size, but sometime more flexibility is needed. See CWM Window Center Move Only for an example of passing values directly.

β€”Change Logβ€”

1.0.0
First public release


Download

Cycling Window Manager 1.0.0 Macros.kmmacros (160.5 KB)

5 Likes

Special thanks to:

I'm trying out releasing the code on GitHub because I think it will be nicer to see different versions over time. That way, anyone can go see what the latest version is or download a previous version if needed. For those unfamiliar with GitHub, use the green code button to download the macros:

1 Like

Congrats on the release! And while Github is fine, I encourage you to also post the initial version hereβ€”just in case your Github account ever vanishes, or users are uncomfortable going there for whatever reason.

-rob.

2 Likes

Noted! I've updated the main post :blush:

This is very cool and super helpful to understand subroutines a bit better as well seeing something so complex. It looks like the GetHub version and the version up top are slightly different.

I also am not getting the results

βŒƒβŒ₯βŒ˜β†β†’ = full screen
βŒƒβŒ₯βŒ˜β†“β†‘ = full screen

Note: these compound hotkeys are most reliable if you hold the keys down for just a moment longer than you would a normal press.

Thanks for sharing.

What differences are you seeing? It's possible I made a mistake since I ended up making multiple changes to the README. The actual macros themselves should be identical though...unless something went really wrong!

The full-screen compound hotkeys are not working for you? Does the window move at all when you do this? How about the quadrants feature (for example *βŒƒβŒ₯βŒ˜β†“ β†’)?

Also, I'd recommend testing the functionality with a Finder window, since sometimes certain windows will have a min or a max size.

I am guessing I just misunderstood what was meant by full screen. It did got the width and half of the full screen and then pressing it a second time made it about a 3rd of that size. There is no full screen shortcut right now as part of it right?

The window should fill all of the available screen but not be in Apple's "Full Screen" mode that hijacks your desktop/space:

That sounds like you are activating the up or down direction repeatedly and cycling from the first option (full width, half height), to the second option (full width, 1/3 height).

No, there is, but because it is a compound shortcut you should press and hold the keys down for a moment longer than normal. It doesn't have to be a full press-and-hold type of thing, but tapping the keys really quickly can be unreliable. The key combination I favor to go directly to full screen is βŒƒβŒ₯βŒ˜β†β†’ = full screen. Just press both arrow keys simultaneously and pause a moment.

1 Like

Oh my goodness, this is awesome and so much I am learning from these macros. I didn't realize you press them both at the same time that is a new one to me. The only thing I am use to holding at the same time is modifiers, this works amazingly well and so many goodies in here I am learning with Dictionaries, and reminders about repeated presses. I went down that path years ago and haven't used that for a while. Thank you for work on this and your post!

I need to learn more about GetHub and all the forks. I keep coming back to that again and again but just need to get over that hurdle. Finally, diving into RegEx deeper.

So I was looking at this further and was going to update and modify it to be able to put the windows in the corners. I love that you included this, my new windows manager and love that I can consolidate more things into Keyboard Maestro. Such and amazing group of shortcuts you made with the multipress options. Thank you again for making and sharing this!!

1 Like

I just discovered your macro form some publication in Reddit, I am trying the functionality and it is really responsive, I am just wondering if there is posible to use or to ser the 1/3 height on the commands for βŒƒβŒ₯βŒ˜β†“β†’ so you can have for example:

βŒƒβŒ₯βŒ˜β† three times and then βŒƒβŒ₯βŒ˜β†“β†’ two times in second and βŒƒβŒ₯βŒ˜β†’β†‘ and same in third window so you organize 3 windows which fits in one screen

This functionality already exist?

I also have a question regarding βŒƒβŒ₯β†’, it works for external screens or it should work to move thru desktops (spaces)?

Thanks you in advance.

Thanks for reaching out! I’m glad to know other people are enjoying these macros too.

I’m not sure I fully understand what you are looking for. Can you describe the end-goal a bit more?

For example, do you want three windows side-by-side in β€œcolumns?” Or three windows side-by-side in β€œrows?”

Do you want one window filling half the screen and the other two windows each filling a quarter of the screen?

A screenshot of the final window layout would be really helpful!

I am refering to use like the Swish function of sixths so you can combine βŒƒβŒ₯βŒ˜β† = left two-thirds (third cycle) and then the option to have two windows in the right one-third, up or down option. Similar behavior could be available with two-thirds (third cycle) for β†’,↓, and ↑

Ah I understand!

That wasn't possible, but I have created a beta version that adds a feature which enables this layout (and even more complex layouts too).

Cycling Window Manager 1.1.0 beta 1 Macros.kmmacros (174 KB)

Use the new compound hotkey βŒƒβŒ₯⌘[] to use the current window to define a sub-region to tile within. Both βŒƒβŒ₯⌘[ and βŒƒβŒ₯⌘] reset the tiling area to the full front-most screen's area. It also resets automatically after 40 seconds.

Now, you should be able to create sixths or even more complex layouts! For sixths, you would first tile a window to be in one-third of the screen. Then, set that third as the tiling region by pressing βŒƒβŒ₯⌘[]. Now you can use βŒƒβŒ₯βŒ˜β†‘ or βŒƒβŒ₯βŒ˜β†“ to tile within the chosen third of the screen, thereby giving you sixths.

Let me know what you think! I still have some issues to work out around the nuances of when the tiling area should be reset. But, I think this beta version should be a good start.

The cycling window manager only supports navigating external screens. Other community members have made macros for navigating between spaces: MACROS: Desktop Spaces β€’ Macros to Improve Navigation and Window Management, v4.0