Disclaimer: The following screenshot is likely unintelligible prior to reading the text included in this post. If fact, it might not provide tangible benefit until one has installed and experimented with this Mission Control Desktop Spaces macro group. With that said, I suspect that new users will find it to be a helpful quick reference.
Introduction
Mission Control Desktop Spaces, a.k.a. Desktop Spaces, a.k.a. macOS virtual Desktops, can be very useful particularly when using a MacBook. Unfortunately, however, configuration and use of Desktop Spaces can be confusing especially when using three or more. The current macOS maximum is 16.
In addition, native macOS does not provide:
-
A visual indication of the Desktop number. Moreover, macOS does not include a public API to determine the Desktop number or to switch Desktop Spaces.
-
A quick method to switch between non-adjacent Desktops.
-
An efficient method to move windows to non-adjacent Desktops
The instruction and macros in this post will address these shortcomings and more.
Requirement and Recommendation
This macro group has one requirements and one recommendations:
-
Keyboard Maestro Version 11+
-
Optional, but strongly recommended: WhichSpace (a free, third-party menu bar application)
Differences/Improvements Versus Superseded Macros
This macro group supersedes all macros found in forum thread Desktop Spaces • Macros for Navigation and Window Management.
Expand for details
-
The macros will be installed in macro group: ⋮sys Desktop Spaces. The group can be renamed, but it is recommended that the macro be kept together.
-
The group consists of 62 macros:
8 Primary Macros, 4 for navigation and 4 for window movement:
- Go Left a Desktop
- Go Right a Desktop
- Go to Application Desktop
- Go to Previous Desktop
- Move Application Window to Current Desktop
- Move Window Left a Desktop
- Move Window Right a Desktop
- Move Window to Previous Desktop
7 Subroutine Macros:
- sub—Activate an App and Wait Until It Is Ready
- sub—Get DesktopNo
- sub—Get DesktopNo_prev
- sub—Go to Desktop N
- sub—Move Window to Desktop N
- sub—Put DesktopNo and/or DesktopNo_prev
- sub—Type Keystroke for Switch to Desktop N
46 Palette Macros
-
Due to the modular design:
-
The macros have been simplified.
-
The 8 primary macros and 7 subroutine macros can easily be used by other macros in the Keyboard Maestro library. Also, macro hot keys and underlying macOS keyboard shortcuts can now be easily changed (if the default configuration causes collisions with existing library macro hot keys and/or macOS keyboard shortcuts).
-
Deleting Previous Versions
Note: It is very important to delete older versions of these macros before completing the installation of Version 4.0.
If you previously installed any macros from the Keyboard Maestro forum threads Desktop Spaces • Macros for Navigation and Window Management or Desktop Spaces • Macros to Improve Navigation and Window Management, complete the following steps:
-
For the .sys Spaces macro group, rename it .sys Spaces-superseded. For the renamed group export it, then delete it.
-
For the .sys Desktops macro group, rename it .sys Desktops-superseded. For the renamed group export it, then delete it.
-
For the .sys Desktop Spaces macro group, rename it .sys Desktop Spaces-superseded. For the renamed group export it, then delete it.
In the unlikely event that it becomes necessary to view the macros deleted above, the exported groups can be imported, but only after installing Version 4.0 below.
Version History
Expand for details
v4.0 (2024-10-21) • Requires Keyboard Maestro Version 11+
Summary of Improvements
-
Hot key changes were made to macros Go to Previous Desktop and Move Window to Previous Desktop necessitated by macOS Sequoia that uses the Keyboard Shortcut ⌃Return to display contextual menus. For more information, see 50 New macOS Sequoia Features and Changes Worth Checking Out - MacRumors (#46).
-
The macro palette (which is optional to use) was updated to reflect the hot key changes noted above.
-
Bug fix: In sub—Go to Desktop N changed Cancel Just This Macro to Return Result. For more information, see "Cancel Just This Macro" in a Subroutine.
macro: Go Right a Desktop
- Modified the logic such that sub—Put DesktopNo and/or DesktopNo_prev is not run if there is an attempt to move beyond the rightmost desktop.
macro: Go to Previous Desktop
- Changed both triggers: a) ⌃Return changed to ⌃⌥Return; b) ⌃⌥Return changed to ⌃⌘Return. This was necessitated by macOS Sequoia that uses the Keyboard Shortcut ⌃Return to display contextual menus. For more information, see 50 New macOS Sequoia Features and Changes Worth Checking Out - MacRumors (#46).
macro: Move Window to Previous Desktop
- Changed trigger from ⌃⌘Return to ⌃⌥⌘Return. This was necessitated by trigger changes to Go to Previous Desktop that were in turn necessitated by macOS Sequoia that uses the Keyboard Shortcut ⌃Return to display contextual menus. For more information, see 50 New macOS Sequoia Features and Changes Worth Checking Out - MacRumors (#46).
macro: sub—Go to Desktop N
- Bug fix: Changed Cancel Just This Macro to Return Result. For more information see "Cancel Just This Macro" in a Subroutine.
macro: sub—Type Keystroke for Switch to Desktop N
-
In the Switch/Case action, changed the condition >= 16 back to >= 16.
-
Enabled Returning a value and return 0 if a local_DesktopNo is a value that is not configured.
macro: 20)Previous ⌃⌥↩
- Renamed from 20)Previous ⌃↩
macro: 43)to Previous [^+click] ⌃⌥⌘↩ [2t]
- Renamed from 43)to Previous [^+click] ⌃⌘↩ [2t]
v3.0 (2024-06-21) • Requires Keyboard Maestro Version 11+
Summary of Improvements
-
Macros Go Left a Desktop (& Move Window Left a Desktop) and Go Right a Desktop (& Move Window Right a Desktop) have been improved:
-
While holding the modifier (default Control ⌃), if the right arrow or left arrow are tapped, the display is moved directly that many Desktop Spaces. For example, if you are viewing Desktop 4 and press and hold Control and tap the right arrow three times, the display will be moved directly to Desktop 7.
-
In contrast, while holding the modifier, if the right or left arrows are held down, the display will be moved right (or left) until the arrow key is released. In this case, all Desktops between the starting point and the ending point will be briefly visible. This method is likely useful if you are searching for a particular window as you are moving through the Desktops.
-
Optionally, when moving a display and window, the display can be returned to the original Desktop Space. Two methods can be used to achieve this optional behavior:
-
via hotkey: hold down the modifier keys and tap the hotkey integer twice.
-
via the Desktop Spaces palette: when clicking the palette item, hold down the Control (⌃) key.
-
-
-
With some limitations, the macro set can now be used without WhichSpace . If it is not installed and running, the Desktop Space Number will not be visible in the macOS menubar. Also, tracking of the current and previous Desktop will be temporarily inaccurate if a Desktop change occurs outside the control of these macros. For example:
-
three-finger swipe left or right on a trackpad
-
Mission Control Desktop Spaces is displayed and a Desktop is selected
-
a macOS application is opened, or activated, and an automatic Desktop change occurs
-
-
The Desktop Space palette has been annotated to indicate items that can be optionally Control (⌃)+clicked and hotkeys that can be tapped twice [2t] or multiple times [mt].
-
Version 3.0 of this macro group includes other improvements detailed below.
macro: Go Left a Desktop
-
Completely rewritten to provide the features described above.
-
Added logic to allow this macro set to run without WhichSpace running, albeit with some limitations.
macro: Go Right a Desktop
-
Completely rewritten to provide the features described above.
-
Added logic to allow this macro set to run without WhichSpace running, albeit with some limitations.
macro: Go to Application Desktop
- Added logic to allow this macro set to run without WhichSpace running, albeit with some limitations.
macro: Go to Previous Desktop
- Added logic to allow this macro set to run without WhichSpace running, albeit with some limitations.
macro: Move Application Window to Current Desktop
- Removed the unnecessary Semaphore Lock.
macro: Move Window Left a Desktop
-
Completely rewritten to provide the features described above.
-
Added logic to allow this macro set to run without WhichSpace running, albeit with some limitations.
macro: Move Window Right a Desktop
-
Completely rewritten to provide the features described in the PURPOSE.
-
Added logic to allow this macro set to run without WhichSpace running, albeit with some limitations.
macro: Move Window to Previous Desktop
- Added logic to optionally return to the original Desktop Space.
macro: sub—Activate an App and Wait Until It Is Ready
- Deselected Returning a value since it was not being used.
macro: sub—Get DesktopNo
-
Added condition to set to -1 if no valid value is retrieved from the dictionary. This handles rare, but possible boundary conditions.
-
Added logic to allow this macro set to run without WhichSpace running, albeit with some limitations.
macro: sub—Get DesktopNo_prev
- Added condition to set to -1 if no valid value is retrieved from the dictionary. This handles rare, but possible boundary conditions.
macro: sub—Go to Desktop N
-
Added logic to allow this macro set to run without WhichSpace running, albeit with some limitations.
-
Reduced execution time by removing a hard-coded pause.
-
Deselected Returning a value since it was not being used.
macro: sub—Move Window to Desktop N
-
Added logic to optionally return to the original Desktop Space.
-
Deselected Returning a value since it was not being used.
macro: sub—Put DesktopNo and/or DesktopNo_prev
-
Simplified the conditional logic since sub—Get DesktopNo and sub—Get DesktopNo_prev were modified to set the value to -1 if no valid value is found.
-
Deselected Returning a value since it was not being used.
macro: sub—Type Keystroke for Switch to Desktop N
-
In the Switch/Case action, changed the condition = 1 to <= 1.
-
In the Switch/Case action, changed the condition = 16 to >= 16.
-
Updated the header comment with updated instructions.
macro: 01)⎯⎯⎯⎯⎯ [ go to Desktop Space ] ⎯⎯⎯⎯⎯
- The macro serves as the left header for the macro set palette. If this header is inadvertently clicked, the macro now properly causes the palette to reappear. From the user's standpoint, this entry now behaves as if it is static text. In Version 2.0, the palette would dismiss.
macro: 24)⎯⎯⎯⎯⎯⎯ [ move Window ] ⎯⎯⎯⎯⎯⎯
- The macro serves as the right header for the macro set palette. If this header is inadvertently clicked, the macro now properly causes the palette to reappear. From the user's standpoint, this entry now behaves as if it is static text. In Version 2.0, the palette would dismiss.
Added palette macros:
- 22)┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
- 23)[ ] == optional; mt == multiple taps
- 45)┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
- 46)^+click or 2 taps of hot key returns to Space
v2.0 (2023-10-27) • Requires Keyboard Maestro Version 11+
Summary of Improvements
-
Forty-three of the fifty-eight macros in this macro group are included in a palette. This palette is displayed using one of the macros in this group, ➜ Desktop Spaces - Show Palette of Macros, that includes a Show Palette of Macros action. By default, the palette can be displayed using ⌃D. Keyboard Maestro Version 11 provides a new feature that allows such palette to have an individual style. This feature has been used to optimize the appearance of the palette for this macro group. Previously the much less flexible Conflict Palette was used.
-
The macro Go to Previous Desktop uses a new Keyboard Maestro Version 11+ trigger When the active space changes. This new trigger enables more robust tracking of Desktop Space changes that are not keyboard-driven (i.e., via trackpad gestures or Mission Control interaction). Previously the The focused window changes was used; it didn't always fire when needed and fired many times when it was not needed.
-
Version 2.0 of this macro group includes many other improvements detailed below.
macro: Go to Application Desktop
- Added a Title to the Prompt With List
macro: Go to Previous Desktop
- Uses the new Keyboard Maestro Version 11+ trigger: When the active space changes (replacing the The focused window changes).
- Changed ⌃⌥Return to display the Previous Desktop Space in large text (replacing a notification).
- Added option to generate a sound when the space is changed. Note that the volume can be changed or the action can be disabled.
macro: Move Application Window to Current Desktop
- The click-and-hold is done using absolute position because, during testing, it was found that with some applications front window top-left corner did not work as expected. Note: Thus far, this does not seem to be an issue if the application is already in the active Desktop Space, therefore the absolute position adjustment has not been made in macros: Move Window Left, Move Window Right, and Move Window to Previous Desktop.
- For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release, changed from 1.0 to 1.5.
macro: Move Window Left a Desktop
- For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release, changed from 1.0 to 1.5.
macro: Move Window Right a Desktop
- For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release, changed from 1.0 to 1.5.
macro: Move Window to Previous Desktop
- For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release, changed from 1.0 to 1.5.
macro: sub—Activate an App and Wait Until It Is Ready
- Removed the Front Window Check and the corresponding variable local_Null FrontWindowName.
- When an About menu is not found, a dialog is generated (replacing a notification). The dialog includes an Edit button which enables a quick method to open this subroutine so that the application can be added to the local_MissingAboutMenuItem variable.
macro: sub—Get DesktopNo
- Removed the local__Notification Level subroutine parameter as it is no longer needed since macro Go to Previous Desktop was changed to use Keyboard Maestro Version 11+ trigger When the active space changes (replacing trigger The focused window changes).
- Moved the WhichSpace AppleScript to a Until action (Timeout set to 5 seconds). The approach previously was to run the AppleScript and then Pause 0.2 seconds.
- If WhichSpace is not running, added a check that the user has been logged in for at least 2 minutes so that the WhichSpace not running dialog does not appear during mac boot up or user login.
macro: sub—Get DesktopNo_prev
- Removed the parameter local__DefaultDesktopNo_prev.
macro: sub—Go to Desktop N
- When attempting to move to a Desktop Space that does not exist, alert using large text (replacing a notification).
macro: sub—Move Window to Desktop N
- Takes no action if local__TargetDesktopNo matches the curent DesktopNo.
- For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release changed from 1.0 to 1.5.
macro: sub—Type Keystroke for Switch to Desktop N
- Removed the otherwise notification since a failure to move to a non-existent Desktop Space is handled in the macro sub—Go to Desktop N.
v1.1 (2022-04-06) • Requires Keyboard Maestro Version 10+
macro: Go to Previous Desktop
- Bug fix: local_dnPreviouslySaved was improperly determined.
macro: Move Window to Previous Desktop
- Removed an extraneous local_dnTarget Set Variable to Text action. No change to macro functionality.
macro: sub—Activate an App and Wait Until It Is Ready
- Added provision for applications that have a null %FrontWindowName%.
v1.0 (2022-03-21) Initial version • Requires Keyboard Maestro Version 10+
Installation
To install Desktop Spaces • Macros to Improve Navigation and Window Management, complete the following:
-
If necessary, using Mission Control, create multiple macOS Desktop Spaces.
-
For macOS Ventura+, configure System Settings > Desktop & Dock > Mission Control.
For macOS pre-Ventura, configure System Preferences > Mission Control.
-
For macOS Ventura+, configure System Settings > Keyboard > Keyboard Shortcuts > Mission Control.
For macOS pre-Ventura, configure System Preferences > Keyboard > Shortcuts > Mission Control.
Specifically, the macOS Mission Control Shortcuts should be configured as follows:
Switch to Desktop 1 to 9 --> ⌃⌥⌘1 to ⌃⌥⌘9
Switch to Desktop 10 to 16 --> ⌃⌥⇧⌘0 to ⌃⌥⇧⌘6
Note: Ideally the macOS Mission Control Shortcuts can be configured exactly as summarized above; however, if any of these shortcuts causes a conflict with an existing Keyboard Maestro hot key, the shortcuts can be customized providing the macro sub—Type Keystroke for Switch to Desktop N is similarly changed. If this becomes necessary, refer to the Type a Keystroke actions.
-
Optionally configure System Settings > Accessibilty > Display.
-
Click to download the following:
Desktop Spaces • Macros to Improve Navigation and Window Management v4.0.zip (298.2 KB)
-
Unzip the download and follow the instructions included in the enclosed _READ ME FIRST_ files.