The macros in this thread prior to 10-March-2021 have been superseded with significantly improved versions. Refer to this entry for more information.
On my MacBook Pro I use up to 15 Desktop Spaces. With several, I've assigned applications to specific spaces, e.g., I've assigned Messages to Desktop 3. With the relatively small footprint of a laptop, the combination of multiple Desktop Spaces and keyboard shortcuts greatly reduces the time and mousing required to manage windows.
Although space-assignment for some apps is certainly beneficial, there are times when windows from these apps need to be visible on other spaces. Movement of such windows with native macOS features is somewhat clumsy, and certainly not done quickly.
Keyboard Mastro, and this set of macros, can greatly assist with this macOS shortcoming and other common Desktop Space tasks even if only a few Desktop Spaces are being used.
Note that all macros below will install in a disabled Keyboard Maestro group named .sys Spaces. The individual macros will be enabled, but they will not be available until the group is enabled.
Macro: Move Window to a Space
The purpose of this macro is to move the active window to a Mission Control Desktop Space.
More
Move window to Space 1 ββ₯1
Move window to Space 2 ββ₯2
Move window to Space 3 ββ₯3
Move window to Space 4 ββ₯4
Move window to Space 5 ββ₯5
Move window to Space 6 ββ₯6
Move window to Space 7 ββ₯7
Move window to Space 8 ββ₯8
Move window to Space 9 ββ₯9
Move window to Space 10 ββ₯A
Move window to Space 11 ββ₯B
Move window to Space 12 ββ₯C
Move window to Space 13 ββ₯D
Move window to Space 14 ββ₯E
Move window to Space 15 ββ₯F
Move window left a space ββ₯β
Move window right a space ββ₯β
The macro completes the move by invoking a click-and-hold on the window followed by typing the keystroke that moves to the target space. Then after a short pause, the click is released and the mouse is returned to its original position.
PREREQUISITE SETTINGS
This macro requires up to the 11 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). The first two must always be set. As up to 9 Desktop Spaces are added, shortcuts ^1 through ^9 must be set. For Spaces 10 to 15, no additional shortcuts are required.
Move left a space ββ₯β§Q
Move right a space ββ₯β§W
Switch to Desktop 1 β1
Switch to Desktop 2 β2
Switch to Desktop 3 β3
Switch to Desktop 4 β4
Switch to Desktop 5 β5
Switch to Desktop 6 β6
Switch to Desktop 7 β7
Switch to Desktop 8 β8
Switch to Desktop 9 β9
ACKNOWLEDGEMENTS
Note: The logic in this macro was taken from macro: Move Frontmost Window to a Different Space
For more information, refer to @Tom's forum post: Move Frontmost Window to a Different Space - Macro Library - Keyboard Maestro Discourse
Three modifications were made for this macro:
-
Expanded to accommodate up to 15 Desktop Spaces
-
Changed the ββ₯Left Arrow and β₯Right Arrow actions. For the rationale, see Peter Lewisβ comment in the forum post.
-
Added logic to exit immediately if the shortcut is invoked in a space without windows
Due to the above changes, the name was changed from Move Frontmost Window to a Different Space to Move Window to a Space.
TESTED WITH
β’ Big Sur, v11.2.1
β’ Keyboard Maestro, v9.2
β’ MacBookPro16,1
VERSION HISTORY
1.0 - Initial version
1.1 - Added back triggers: ββ₯β and ββ₯β. They were mistakenly removed before v1.0 was uploaded.
Move Window to a Space, v1.1, 2021-02-25
DOWNLOAD Macro File:
.sys Spaces Macros.kmmacros (272 KB)
Although not required for the operation of any other macros in this post, these two simple macros, in combination with the native macOS keyboard shortcuts, can be used to navigate a Desktop Space left (ββ) and right (ββ), respectively.
Move Left a Space, v1.1, 2021-02-26
Move left a space ββ₯β
DOWNLOAD Macro File:
Move Left a Space.kmmacros (4.7 KB)
Move Right a Space, v1.1, 2021-02-26
Move right a space ββ₯β
DOWNLOAD Macro File:
Move Right a Space.kmmacros (4.7 KB)
Macro: Return to Previous Space
This macro is used to return to the previously displayed Mission Control Desktop Space. For example, if Space 5 is visible and ^2 is used to move to Space 2, ^Return will return to Space 5. Since a second ^Return will move back to Space 2, this macro makes it easy to toggle between two Desktop Spaces, even if they are nonadjacent.
More
Return to Previous Space βReturn
Note 1: Fundamental to the operation of this macro, the current Desktop Space number must be determined. This value is not available using native Keyboard Maestro actions because, according the this comment from @peterlewis, the space number is not available via a public API. Therefore, a third-party menubar open source tool named WhichSpace and AppleScript are required for this macro. See below for more information.
Note 2: This macro records a space change by detecting if the focused window title changes. Generally this works well because a user is typically toggling between spaces to use different applications or at least different windows within the same application. If however, a user changes to another space that has the same foreground window active, the previous space will not be updated, thus this macro may return to an unexpected space when it is invoked by ^Return.
PREREQUISITE SETTINGS
This macro requires up to the 11 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). The first two must always be set. As up to 9 Desktop Spaces are added, shortcuts ^1 through ^9 must be set. For Spaces 10 to 15, no additional shortcuts are required.
Move left a space ββ₯β§Q
Move right a space ββ₯β§W
Switch to Desktop 1 β1
Switch to Desktop 2 β2
Switch to Desktop 3 β3
Switch to Desktop 4 β4
Switch to Desktop 5 β5
Switch to Desktop 6 β6
Switch to Desktop 7 β7
Switch to Desktop 8 β8
Switch to Desktop 9 β9
OTHER DEPENDENCY
The free open source application WhichSpace must be running. The author of WhichSpace, George Christou, kindly told me that the value displayed by WhichSpace could be returned using the AppleScript included within this Marco.
LIMITATIONS
As configured, this macro is limited to Desktop Spaces 1 to 15.
TESTED WITH
β’ Big Sur, v11.2.1
β’ Keyboard Maestro, v9.2
β’ MacBookPro16,1
VERSION HISTORY
1.0 - Initial version
1.1 - Updated the macro name in this comment from Return to the Previous Space to Return to Previous Space. There is no functional change to this macro.
Return to Previous Space, v1.1, 2021-02-26
DOWNLOAD Macro File:
Return to Previous Space.kmmacros (41 KB)
Macro: Move Window to the Previous Space
The purpose of this macro is to move the active window to the previously displayed Mission Control Desktop Space.
More
Move window to Previous Space ββ₯Return
For example, if Space 5 is visible and ^2 is used to move to Space 2, ^β₯Return will return the active window on Space 2 to Space 5. Since a second ^β₯Return will move the window back to Space 2, this macro makes it easy to toggle between two Desktop Spaces, even if they are nonadjacent.
Note: Fundamental to the operation of this macro, the current Desktop Space number must be determined. This value is not available using native Keyboard Maestro actions because, according the this comment from @peterlewis, the space number is not available via a public API. Therefore, a third-party menubar open source tool named WhichSpace and AppleScript are required for this macro, See below for more information.
PREREQUISITE SETTINGS
This macro requires up to the 11 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). The first two must always be set. As up to 9 Desktop Spaces are added, shortcuts ^1 through ^9 must be set. For Spaces 10 to 15, no additional shortcuts are required.
Move left a space ββ₯β§Q
Move right a space ββ₯β§W
Switch to Desktop 1 β1
Switch to Desktop 2 β2
Switch to Desktop 3 β3
Switch to Desktop 4 β4
Switch to Desktop 5 β5
Switch to Desktop 6 β6
Switch to Desktop 7 β7
Switch to Desktop 8 β8
Switch to Desktop 9 β9
OTHER DEPENDENCY
The free open source application WhichSpace must be running. The author of WhichSpace, George Christou, kindly told me that the value displayed by WhichSpace could be returned using the AppleScript included within this Marco.
LIMITATIONS
As configured, this macro is limited to Desktop Spaces 1 to 15.
TESTED WITH
β’ Big Sur, v11.2.1
β’ Keyboard Maestro, v9.2
β’ MacBookPro16,1
VERSION HISTORY
1.0 - Initial version
Move Window to the Previous Space, v1.0, 2021-02-26
DOWNLOAD Macro File:
Move Window to the Previous Space.kmmacros (35 KB)
Macro: Move Window to the Current Space
The purpose of this macro is to move a window from another Mission Control Desktop Space to the Current Space.
More
Move window to Current Space ββ₯0
When the macro is invoked, a list of running applications will appear in a prompt list. When one of the applications is selected, the macro will move to the Space where the active window for the applications resides. The window will then be moved to the Current Space.
The window move is done by invoking a click-and-hold on the upper-left of the window followed by typing the keystroke that moves back to the Current Space. Then after a short pause, the click is released and the mouse is returned to its original position.
PREREQUISITE SETTINGS
This macro requires up to the 11 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). The first two must always be set. As up to 9 Desktop Spaces are added, shortcuts ^1 through ^9 must be set. For Spaces 10 to 15, no additional shortcuts are required.
Move left a space ββ₯β§Q
Move right a space ββ₯β§W
Switch to Desktop 1 β1
Switch to Desktop 2 β2
Switch to Desktop 3 β3
Switch to Desktop 4 β4
Switch to Desktop 5 β5
Switch to Desktop 6 β6
Switch to Desktop 7 β7
Switch to Desktop 8 β8
Switch to Desktop 9 β9
OTHER DEPENDENCIES
-
The free open source application WhichSpace must be running. The author of WhichSpace, George Christou, kindly told me that the value displayed by WhichSpace could be returned using the AppleScript included within this Marco.
-
The Activate an Application by Name action, available by a custom Keyboard Maestro Plug-in, by @ComplexPoint, must be installed.
LIMITATIONS
As configured, this macro is limited to Desktop Spaces 1 to 15.
TESTED WITH
β’ Big Sur, v11.2.1
β’ Keyboard Maestro, v9.2
β’ MacBookPro16,1
VERSION HISTORY
1.0 - Initial version
Move Window to the Current Space, v1.0, 2021-02-22
DOWNLOAD Macro File:
Move a Window to the Current Space.kmmacros (36 KB)
SUMMARY OF NATIVE KEYBOARD SHORTCUTS AND MACRO HOT KEYS
The macOS native keyboard shortcuts and macros detailed above will enable efficient spaces navigation and window movement. This section includes a summary.
More
Space Navigation
Move left a space ββ
Move right a space ββ
Switch to Desktop 1 β1
Switch to Desktop 2 β2
Switch to Desktop 3 β3
Switch to Desktop 4 β4
Switch to Desktop 5 β5
Switch to Desktop 6 β6
Switch to Desktop 7 β7
Switch to Desktop 8 β8
Switch to Desktop 9 β9
Return to Previous Space βReturn
Navigation beyond Space 9 can be done two ways:
-
β9, followed by the required number of ββ
-
By opening or activating an application that has been assigned to the space. (This method can be used for any of the 15 spaces.)
Window Movement
Move window left a space ββ₯β
Move window right a space ββ₯β
Move window to Current Space ββ₯0
Move window to Space 1 ββ₯1
Move window to Space 2 ββ₯2
Move window to Space 3 ββ₯3
Move window to Space 4 ββ₯4
Move window to Space 5 ββ₯5
Move window to Space 6 ββ₯6
Move window to Space 7 ββ₯7
Move window to Space 8 ββ₯8
Move window to Space 9 ββ₯9
Move window to Space 10 ββ₯A
Move window to Space 11 ββ₯B
Move window to Space 12 ββ₯C
Move window to Space 13 ββ₯D
Move window to Space 14 ββ₯E
Move window to Space 15 ββ₯F
Move window to Previous Space ββ₯Return
MANAGING SPACES WITH A PALETTE
If the macros in this section are downloaded and installed (along with the macros from above), the functions described above can be optionally controlled using one hot key (default: ^S) which opens a Keyboard Maestro Conflict Palette.
More
Because it is a little faster, I normally navigate spaces and complete related window moves using the macOS native Mission Control Keyboard Shortcuts and the hot keys defined within the four macros above; but the palette can be helpful for a new user.
TESTED WITH
β’ Big Sur, v11.2.1
β’ Keyboard Maestro, v9.2
β’ MacBookPro16,1
VERSION HISTORY
1.0 - Initial version
2.0 - a) Added a palette macro to launch the new macro above named Move Window to the Previous Space. b) Added palette spacers/labels to annotate the palette entries.
Managing Spaces with a Palette, v2.0, 2021-02-26
The following download will replace all of the palette macros from Version 1.0; thus before downloading and installing, move to the Keyboard Maestro group named .sys Spaces and delete all of the macros that are triggered by ^S.
DOWNLOAD Macro Files (36):
sys Spaces Macros.kmmacros (151.6 KB)