MACROS: Desktop Spaces • Macros for Navigation and Window Management, v1.1 (Superseded)

Version History




All information below refers to the macros that were originally shared in this thread.


v1.1 (2021-10-22) The nine primary macros have been updated as follows:

Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value
I've never observed a triplet, but @seishonagon did and suggested this change which accommodates those that do and has no effect on those that don't.

Macro Move Application Window to Current Desktop has one additional modification:

Removed use of custom Keyboard Maestro Plug-in action (Activate an Application by Name) and replaced with Execute Shell Script command (open -a "$KMVAR_local__AppSelected”) followed by AppleScript command (activate).

This modification was suggested by @ccstone via a PM. He also suggested the zip file organization used below.

The optional forty-two Conflict Palette macros have not been modified.

v1.0 (2021-03-10) Initial version


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.
  • 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.


Quick Start

If you previously installed the Desktop Spaces • Macros for Navigation and Window Management macros, complete the following:

  1. If it exists, disable the .sys Spaces macro group. Rename it .sys Spaces - superseded.

  2. If it exists, disable the .sys Desktops macro group. Rename it .Sys Desktops - v1.0 superseded.

Afer completing the installation steps below, optionally come back and delete these two disabled macro groups and all macros within.

To install Desktop Spaces • Macros for Navigation and Window Management v1.1, complete the following:

  1. If necessary, using Mission Control, create multiple macOS Desktop Spaces.

  2. Configure System Preferences > Mission Control.

  3. Configure System Preferences > Keyboard > Shortcuts > Mission Control.

    Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
    Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6
    

  4. Double-click to download the following:
    Desktop Spaces - Macros for Navigation and Window Management.zip (108.0 KB)

  5. Unzip the download; open the included folder. Three subfolders will be enclosed:

    a. [ Required Step ] Open subfolder 1 - Required. Double-click 9 Primary Macros.kmmacros to install the primary macros. Note that the macros will individually ENABLED; but the macro group .sys Desktops will be DISABLED. When ready to use the macros, enable this group.

    b. [ Optional Step ] Open subfolder 2 - Optional but highly recommended. Double-click WhichSpace – Download Latest Release.webloc to install this free, open-source application that displays the Mission Control Desktop Space number in the mac menubar. Set WhichSpace to open (start) during each login.

    c. [ Optional Step ] Open subfolder 3 - Optional but helpful for beginners or occassional users. Double-click 42 Palette Macros.kmmacros to install the optional palette macros. Note that theses macros will also be installed in the .sys Desktops macro group and be ENABLED.


Macro Improvements and Limitations

This set of macros includes several improvements:

  • Support for all 16 Mission Control Desktop Spaces
  • Macro names include the word Desktop rather than Space since this is a more mainstream term for virtual desktops
  • All macros are installed in a group named: .sys Desktops (versus .sys Spaces). Like before the macro group is initially disabled when the macros are downloaded.
  • More reliable tracking of the Current Desktop Number since a macro Go to Desktop N (Desktops 1 to 16: ⌃1 .. ⌃9, ⌃⇧0 .. ⌃⇧6) has been added for basic navigation
  • Moving desktop right (⌃Right Arrow) and desktop left (⌃Left Arrow) have been improved:
    • animation gives better feedback than the macOS native Mission Control Keyboard Shortcuts Move left a space and Move right a space
    • thanks to the macro MACRO: HotKey Multi-Press Template, by @DanThomas, multiple taps on the arrow keys are recognized
    • holding arrow keys repeats the movement left or right until the keys are released
    • the previous Desktop is retained to the desktop that was active when the left or right movement began. For example, if one started on Desktop 1, and triple-tapped ⌃Right Arrow to move to Desktop 4 (Desktop 1 -> Desktop 2 -> Desktop 3 -> Desktop 4), subsequent use of ⌃Return would return to Desktop 1 (not Desktop 3).
  • For the macro Move Application Window to Current Desktop (⌃⌘0), Applications to Exclude can be configured (by default LaunchBar and Amphetamine are excluded).
  • The optional Conflict Palette (⌃S) displays all of the hot keys for the nine underlying macros. The forty-two Conflict Palette macros have been simplified to use the Trigger Macros by Hot Key action
  • Most of the functionality of these macros will now work independent of WhichSpace. However, without it, the following features will be absent:
    • The visual indication of the Desktop Number rendered by WhichSpace on the macOS menubar

    • The tracking of the current and previous Desktop will be temporarily inaccurate if a Desktop change occurs outside the control of the macros. For example,

      • three-finger swipe left or right on a trackpad
      • Mission Control is displayed and a Desktop is selected
      • a macOS application is opened, or activated, and an automatic Desktop change occurs (see Note 1)

      So what’s the impact? Go to Previous Desktop (Return) will return to the last Desktop that was displayed using a macro hot key. For example:

      1. Moved to Desktop 4 using ⌃4
      2. Moved to Desktop 3 using a three-finger swipe on the trackpad
      3. Moved to Desktop 1 using ⌃1
      4. Go to Previous Desktop (⌃Return) would move to Desktop 4 (not Desktop 3)

Note 1: This can occur when the following is selected (highly recommended): System Preferences > Mission Control > When switching to an application, switch to a Space with open windows for the application


Nine Primary Macros

This section includes more information and images for each of the nine primary macros. The Go to Previous Desktop section provides a comprehensive explanation for those interested in the inner workings. This information is also available in the comments of each macro.

All macros can be downloaded as a group using the link in the Quick Start section.


Macro: Go to Desktop N

This macro is used to directly move to one of the sixteen Desktops.

Go to Desktop 1 .. 9                             ⌃1 .. ⌃9
Go to Desktop 10 .. 16                           ⌃⇧0 .. ⌃⇧6
More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value


Macro: Go Left a Desktop

This macro is used to move left one or more Desktops.

Go Left a Desktop				                 ⌃Left Arrow

In addition to a single press of ⌃Left Arrow, multiple taps of the Left Arrow (while ⌃ is down) will be recognized. Also, if ⌃Left Arrow is held down, the movement left is repeated until released.

More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

ACKNOWLEDGEMENT
The multiple-tap capability of this macro is provided by MACRO: HotKey Multi-Press Template, by @DanThomas.

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value


Macro: Go Right a Desktop

This macro is used to move right one or more Desktops.

Go Right a Desktop			                     ⌃Right Arrow

In addition to a single press of ⌃Right Arrow, multiple taps of the Right Arrow (while ⌃ is down) will be recognized. Also, if ⌃Right Arrow is held down, the movement right is repeated until released.

More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

ACKNOWLEDGEMENT
The multiple-tap capability of this macro is provided by MACRO: HotKey Multi-Press Template, by @Dan Thomas.

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value


Macro: Go to Previous Desktop

This macro is used to return to the previously displayed Desktop.

Go to Previous Desktop                           ⌃Return

For example, if Desktop 5 is visible and ⌃2 is used to move to Desktop 2, ⌃Return will return to Desktop 5. Since a second ⌃Return will move back to Desktop 2, this macro makes it easy to toggle between two Desktops, even if they are nonadjacent.

Note: If the macro is triggered with the ⌥ (Option key) down, the desktop change will not occur; instead a brief message will appear indicating the previously displayed Desktop.

More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

:warning:OPERATIONAL DETAILS
According to this comment from @peterlewis, the Desktop number is not available via macOS public API, thus there is no native Keyboard Maestro action for this purpose. However, when Desktop navigation and window movement are done exclusively with this macro and the others in the macro group (see Note 1) the current and previous Desktop numbers are accurately tracked and saved using Keyboard Maestro global variables. This is useful and often sufficient but there will be times when a Desktop change occurs outside the domain of the macros in this group. For example:

a. three-finger swipe left or right on a trackpad
b. Mission Control is displayed and a Desktop is selected
c. a macOS application is opened, or activated, and an automatic Desktop change occurs (see Note 2)

In these cases, and possibly others, the tracking of the current and previous Desktop will be temporarily inaccurate (see Note 3) unless a helper application named WhichSpace is installed. (This installation is highly recommended, but not required.)

WhichSpace is a free, open source application by George Christou that displays the Desktop number in the macOS menubar. This indication is of great value when using multiple Desktops. As a bonus and employed within this macro, the Desktop number can be determined with a simple AppleScript (see Note 4).

Note 1: Other macros in this macro group are:
Go Left a Desktop, Go Right a Desktop, Go to Desktop N, Move Application Window to Current Desktop, Move Window Left a Desktop, Move Window Right a Desktop, Move Window to Desktop N, Move Window to Previous Desktop)

Note 2: Automatic Desktop changes can occur when the following is selected: System Preferences > Mission Control > When switching to an application, switch to a Space with open windows for the application

Note 3: If WhichSpace is not installed, current and previous Desktops can be temporarily inaccurate. For example:

a. Move to Desktop 4 using macro Go to Desktop N (⌃4).
b. Move to Desktop 3 using trackpad
c. Move to Desktop 1 using macro Go to Desktop N (⌃1).
d. Running this macro, Go to Previous Desktop (⌃Return) would move to Desktop 4, not Desktop 3.

Note 4: When WhichSpace is installed, this macro records a desktop change by detecting if the focused window title changes. Generally this works well because when a desktop change occurs (even outside the control of the macros in this group) different applications or at least different windows within the same application are made automatically active or selected by a user. However, there may be rare situations when a desktop change is made, outside the domain of these macros, and the window title does not change, thus the previous and current Desktop tracking will be temporarily inaccurate.

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value


Macro: Move Window to Desktop N

This macro is used to move the active window to one of the sixteen Desktops.

Move Window to Desktop 1 .. 9                    ⌃⌘1 .. ⌃⌘9
Move Window to Desktop 10 .. 16                  ⌃⇧⌘0 .. ⌃⇧⌘6

The macro completes the move by invoking a click-and-hold on the upper-left of 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.

More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

ACKNOWLEDGEMENT
The logic in this macro was taken from Move Frontmost Window to a Different Space, by @Tom.

Two modifications were made for this macro:

  1. Expanded to accommodate up to 16 Desktop Spaces
  2. 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 Desktop N.

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value


Macro: Move Window Left a Desktop

This macro is used to move the active window left one or more Desktops.

Move Window Left a Desktop                       ⌃⌘Left Arrow

In addition to a single press of ⌃⌘Left Arrow, multiple taps of the Left Arrow (while ⌃⌘ are down) will be recognized. Also, if ⌃⌘Left Arrow is held down, the movement left is repeated until released.

More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

ACKNOWLEDGEMENT
The multiple-tap capability of this macro is provided by MACRO: HotKey Multi-Press Template, by @DanThomas.

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value


Macro: Move Window Right a Desktop

This macro is used to move the active window right one or more Desktops.

Move Window Right a Desktop                      ⌃⌘Right Arrow

In addition to a single press of ⌃⌘Right Arrow, multiple taps of the Right Arrow (while ⌃⌘ are down) will be recognized. Also, if ⌃⌘Right Arrow is held down, the movement left is repeated until released.

More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

ACKNOWLEDGEMENT
The multiple-tap capability of this macro is provided by MACRO: HotKey Multi-Press Template, by @DanThomas.

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value


Macro: Move Window to Previous Desktop

This macro is used to move the active window to the previously displayed Desktop.

Move Window to Previous Desktop                  ⌃⌘Return

For example, if Space 5 is visible and ⌃2 is used to move to Space 2, ⌃⌘Return will move 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: If the macro is triggered with the ⌥ (Option key) down, the window move will not occur; instead a brief message will appear indicating the previously displayed Desktop.

More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value


Macro: Move Application Window to Current Desktop

This macro is used to move a window from another Desktop to the current Desktop.

Move Application Window to Current Desktop       ⌃⌘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 Desktop where the active window for the applications appears. The window will then be moved to the current Desktop.

The window move is done by invoking a click-and-hold on the upper-left of the window followed by typing the key stroke that moves back to the current Desktop. Then after a momentary pause, the click is released and the mouse is returned to its original position.

More

PREREQUISITE SETTINGS
This macro requires up to the 16 native macOS keyboard shortcuts below to be set (System Preferences > Keyboard > Shortcuts > Mission Control). These must be set as Desktop Spaces are added.

Switch to Desktop 1 .. 9                         ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16                       ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

:warning:OTHER DEPENDENCIES
a. The following must be set: System Preferences > Mission Control > When switching to an application, switch to a Space with open windows for the application.
b. The Activate an Application by Name action, available by a custom Keyboard Maestro Plug-in, by @ComplexPoint, must be installed.

OPERATIONAL DETAILS
When the window switching occurs during the execution of this macro, the previous Desktop will be updated to the Desktop that includes the target application window (see Note 1). This default behavior is normally desirable as it makes it easy to return the moved window to its original Desktop using the macro Move Window to Previous Space (⌃⌘Return).

In rare situations it may be desirable to preserve the pre-window move previous Desktop. To do this, include the ⌥ (Option) key when launching this shortcut.

Note 1: If WhichSpace is not running, this update of the previous Desktop will not occur. For more WhichSpace information, refer to the the macro Go to Previous Desktop.

APPLICATIONS TO EXCLUDE
By default, this macro will ignore two applications: LaunchBar and Amphetamine. To add others, modify the list in the specified action below.

TESTED WITH
• Big Sur, v11.6
• Keyboard Maestro, v9.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version
1.1 - Modified WhichSpace AppleScript to handle cases where the window title is returned as a triplet, that is: n, missing value, missing value

7 Likes

Hi,
I'm trying to use your - brilliant - macro system but I'm running into an issue:

It seems that the Variable jsMCDS_DesktopNo is set to 1, missing variable and thus all the "go right", "go left", "go to previous" macros fail.


The Variable jsMCDS_DesktopNo_Prev doesn't even seem to be set anywhere.


I've tried to install it from scratch twice and the same thing happens each time.

Not sure how to debug. Can you help?

Thanks!

@seishonagon, let's try a few basics first. If that doesn't work, then I'll need a more detailed description of the steps you are trying to execute.

  • WhichSpace must be running.
  • The macOS Keyboard Shortcuts (e.g., ⌃⌥⌘1...) must be defined.
  • jsMCDS__DesktopNo_prev (note the two underscores after jsMCDS) will not be defined immediately after installing the macros and related components. Try this: ⌃⌥⌘1 to move to Desktop 1; ⌃⌥⌘2 to move to Desktop 2. Then jsMCDS__DesktopNo_prev should be defined and ⌃Return should function as expected.

Hey, thanks for your reply.

  • WhichSpace is running
  • The keyboard shortcuts are defined as needed up to number 16
  • moving to spaces by their number (e.g. ⌃⌥⌘1, ⌃⌥⌘2 ...) works as expected.

But if I type ⌃⌥Return, I get the following dialog:

and then an error message:

Sorry, in my previous reply I should have said:

Try this: ⌃1 to move to Desktop 1 ; ⌃2 to move to Desktop 2 . Then jsMCDS__DesktopNo_prev should be defined and ⌃Return should function as expected.

Note: ⌃n ( n = 1 to 16 ) will save the previous desktop to the jsMCDS__DesktopNo_prev variable (even if WhichSpace is not running).

Nope ... but I think I got it:
In script debugger, your line:

tell application "System Events" to tell process "WhichSpace" to title of menu bar items of menu bar 1

returns a triplet, e.g: 2, missing value, missing value
which is then saved to a KM variable which SHOULD be an integer but is a string. And so subsequent calculations don't work.
Replacing the script by

tell application "System Events" ¬
to tell process "WhichSpace" ¬
to set temp to (title of menu bar items of menu bar 1)
return item 1 of temp

works like a charm!

I don't know if the AS dictionnary of WhichSpace changed, ( I installed it via homebrew?) but there you have it !

Thanks for the set of macros, very useful.

Ha, I was about to send you a macro that isolated the AppleScript for WhichSpace. But you were one step ahead of me! I love it! As a reward, you get to run these macros at half price! :wink:

(I was thinking that the AppleScript was failing, but not as you discovered. As written, the macros will run when WhichSpace is not running, but not when WhichSpace returns the unexpected results.)

Interesting, not on my systems. I'm running WhichSpace 0.3.2 and Keyboard Maestro 9.2 on two systems:

  • 16" MBPro, macOS 11.2.3
  • Mac mini (Late 2012), macOS 10.14.6

But regardless, as I'm sure you know, the modified AppleScript will run just fine on systems that only return one value.

One word of caution: You will find this AppleScript sprinkled throughout the macros so your fix will need to inserted several places. As you go through the macros, be sure to expand each section.

Several weeks ago, @ccstone gave me some constructive feedback and suggested a simplified install process. Now I have another reason to get that done. All I need is a little free time. :grinning:

You're welcome, @seishonagon. Thanks for the messages and troubleshooting.

Hi jims, thanks for the great work!
The conflict palette is especially useful.

To display it in two column, need to set the Conflict Palette Style in the Preferences of Keyboard Maestro.

@xsmk, glad you like it. Thanks for the comment.

Thanks for pointing that out. When I repost this with a few refinements, I'll add that comment.

For the sake of argument, let's say that the shortcuts that you have me set my mission control shortcuts to are taken (these guys):

Switch to Desktop 1 .. 9 ⌃⌥⌘1 .. ⌃⌥⌘9
Switch to Desktop 10 .. 16 ⌃⌥⇧⌘0 .. ⌃⌥⇧⌘6

Digging around the various macros in the bundle of 9.... I found *Switch of Text “%Variable%local__dnTarget%” sections to be the only thing referencing those short cuts. Assuming I go update that section, in each of the 9 macros, are there any other places that I need to go update to make match the shortcuts that I did set my "Switch Desktop" commands to?

i.e.

If it is “1”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘1 Keystroke[image]

If it is “2”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘2 Keystroke[image]

If it is “3”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘3 Keystroke[image]

If it is “4”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘4 Keystroke[image]

If it is “5”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘5 Keystroke[image]

If it is “6”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘6 Keystroke[image]

If it is “7”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘7 Keystroke[image]

If it is “8”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘8 Keystroke[image]

If it is “9”, Execute the Following Actions:

  • [image]Type the ⌃⌥⌘9 Keystroke[image]

If it is “10”, Execute the Following Actions:

  • [image]Type the ⌃⌥⇧⌘0 Keystroke[image]

If it is “11”, Execute the Following Actions:

  • [image]Type the ⌃⌥⇧⌘1 Keystroke[image]

If it is “12”, Execute the Following Actions:

  • [image]Type the ⌃⌥⇧⌘2 Keystroke[image]

If it is “13”, Execute the Following Actions:

  • [image]Type the ⌃⌥⇧⌘3 Keystroke[image]

If it is “14”, Execute the Following Actions:

  • [image]Type the ⌃⌥⇧⌘4 Keystroke[image]

If it is “15”, Execute the Following Actions:

  • [image]Type the ⌃⌥⇧⌘5 Keystroke[image]

If it is “16”, Execute the Following Actions:

  • [image]Type the ⌃⌥⇧⌘6 Keystroke[image]

Thanks!

Geoff

@Geoffrey_Blotter, no guarantees, but I think you have identified the only change required. I'm sure you noticed that this Switch/Case macro action is distringuished by the purple color. So if you modify the keystrokes within one macro, you can copy that modified Switch/Case action and paste it in the other eight macros (of course also discarding the original Switch/Case actions in each of the eight target macros). The copy-and-paste technique will greatly minimize the work and reduce the probability of an improper modification.

You're a gem for pointing that out, thanks!

I'll make that change and try and report back if that was the only place or not, for documentation purposes. Thanks @_jims!

Out of curiosity, and a fear of making unintended downstream impacts... Can I ask why the first step is to go remap default keyboard shortcuts for switching to different Desktops? i.e. why not use the default values?

Thanks again for making this killer set of macros :blush:

Yes, this seems like a bit of a pain, but there is a good reason.

These macros track the current and previous desktop space number (1 to 16). This, however, can only be done reliably if desktop navigation is done exclusively using one of the nine macros. That is, if one were to change spaces using one of the macOS native Switch to Desktop N (1 to 16) shortcuts (or a trackpad gesture), the current and previous values would be temporarily incorrect. That's why users should use the Go to Desktop N macro rather than the native macOS Switch to Desktop N shortcuts to change desktop spaces. The key remapping suggested in the Quick Start (more complex key combinations), and the macro hot keys used in the nine macros (more intuitive key combinations) encourage this behavior.

Here's some related information...

Within Keyboard Maestro, macro-initiated desktop space changes can only be accomplished with the Type a Keystroke action. That is, Keyboard Maestro does not provide change desktop actions. This is for good reason: Apple does not provide a corresponding public API. Due to the missing API, desktop space changes also cannot be done with an AppleScript or a shell script.

Finally, Keyboard Maestro does not provide a token or action to determine the current desktop space. Same reason: no API. Thus, a third-party tool named WhichSpace is used in the macros (via AppleScript) to determine the current desktop space.

@seishonagon, I was never able to reproduce the issue you identified; nevertheless, I implemented your change into v1.1 of the macros.

Thanks again!

1 Like

@xsmk, I added this comment into a Read Me First file that is downloaded with v1.1 of the macros.

Thanks again for your feedback!

UPDATE NOTICE

I've updated the Desktop Spaces • Macros for Navigation and Window Management macros to v1.1. I've also simplified the installation process.

The macro changes are somewhat minor; if you have previously installed the macros and they are working as expected, you can ignore the updates.

See the Version History for more information.

1 Like

Makes complete sense. Thank you for the thoughtful reply.

1 Like

When I attempted to install the macros, for simplicity I decide to only do Step 5.a. and omit the optional steps 5.b and 5.c.

Nothing worked. Nada.

I started poring over the macros, trying to trace out the problem and got nowhere. Then I noticed that the .sys Desktops folder was greyed out in the KBM editor. Huh? I distinctly remembered the instructions saying that it was installed in an "ENABLED" state.

Oh! The text says that each of the macros will be enabled. And Lo! And Behold! There's Step 6 as a single line, hiding under the palette screenshot, camouflaged as an image caption. Clearly the instructions are correct, but subject to misinterpretation (at least for one data point).

May I suggest that in Step 5a, where you say,

that you also say, "The .sys Desktops groups is initially disabled and will be enabled in Step 6."

Thanks.

1 Like

@August, thanks for the feedback. I've removed Step 6 and modified Step 5a:

[ Required Step ] Open subfolder 1 - Required. Double-click 9 Primary Macros.kmmacros to install the primary macros. Note that the macros will individually ENABLED; but the macro group .sys Desktops will be DISABLED. When ready to use the macros, enable this group.