MACROS: Desktop Spaces • Macros to Improve Navigation and Window Management, v2.0

@_jims After deleting the prior version of the macros and installing the version from this thread I'm still having difficulties :frowning_face:

I'm running 12.4 on an M1 Mini. I've set the desktop shortcuts as requested and they work. I have Whichspace running.

  • Using Cntl Arrows to move between spaces works!
  • Using Cntl-Cmd Arrow to move an app right or left a desktop results in the cursor moving to the upper left corner, then moving back to it's prior position.
  • Cntl-Cmd 2 also moves the cursor in the same way.

I downloaded your test script zGetDesktopNo Test.kmmacros and my results look like yours.

Thanks for any help you can give.

Again @blfarris, sorry to hear about these difficulties. But I suspect we'll be able to get this resolved.

I'm using 12.4.1 on my Intel MacBook Pro.

I'm using Keyboard Maestro, Version 10.0.2. What's your version?

I'm using WhichSpace, Version 0.3.2. What's your version?


Please share a screenshot of your Mission Control Shortcuts. You may not have 8+ Mission Control Desktops, but it should look similar to this:


If your Move left a space and Move right a space Shortcuts are unchecked (screenshot above), this is encouraging as it indicates that a large portion of the macro logic is performing as expected.

If you haven't done so already, please use ⌃← to move to Desktop 1. From there, use ⌃→ repeatedly to move to Desktop n.

Also, using the Conflict Palette, please test desktop space navigation to all of your Desktops:

  • Display the palette using ⌃D.
  • Click on an entry in the [ go to Desktop ] section.
  • Repeat for all of your Desktops.

If any of this navigation does no work as expected, please let me know.

That arrow movement is expected. The macros move windows by clicking-and-holding the mouse in the upper-left region of a window, navigating to the target desktop space, and then releasing the mouse and returning the arrow to the original location.

For some reason, yet determined, the navigation portion of that sequence is not working as expected.

AH! There it is, I had my shortcuts wrong for the desktops. All working well now!

Thanks @_jims

One question about the conflict palette, how do you trigger any of the move window triggers? I'm used to a conflict palette where each of the macros start with a different letter and I can just start typing to trigger them. But that's not really working in this palette since they all start with "to".

Thanks again for all your help -- I'm a relative beginner with this tool but it's helping me a bunch!

1 Like

Great @blfarris, glad you found the configuration issue.

First, your Conflict Palette will look different than mine unless you have your Keyboard Maestro Preference set as follows (Keyboard Maestro > Preferences... > Palettes (section) > Conflict Palette Style):


Then you can display the Conflict Palette using ⌃D. Note that all of the entries in the right column begin with a dim t.


If you press t, the Conflict Palette will display the right column items. Then if you press 1, macro 24)to 1 ⌃⌘1 will run.


Additional Conflict Palette information:

  • The Conflict Palette macros are named such that all can be launched with one (left column items) or two characters (right column items).

  • You don't need to wait for the right column items to be displayed. That is, you could run macro 24)to 1 ⌃⌘1 by quickly pressing t1.

  • Some of the macro names include the hotkey that will directly launch the underlying macros (bypassing the Conflict Palette altogether). Other macro names don't include the hotkey (I choose to exclude some to reduce Conflict Palette clutter.), but all underlying macros do include a hotkey trigger. For example, the following hotkeys will run the macros that:

    • ⌃7 navigate to Desktop 7
    • ⌃⇧⌘1 move the active window to Desktop 11
    • ⌃↩︎ navigate to Previous Desktop
    • ⌃⌘0 move an Application Window to the Current Desktop

@_jims Thanks for your generosity and help! I think I've got it now.

I'm going to start playing with these, they are giving me some great ideas for new macros, like "Open a Safari window in the current space"

Brad

1 Like

If you want to leverage the subroutines in this macro set, check out this thread: Workspaces in Mission Control Desktop Spaces - Questions & Suggestions - Keyboard Maestro Discourse

In that thread you'll see a palette that I use that includes a macro named New Safari Window Here. I'd be glad to share that macro if you'd like.

@_jims I'd love to see that macro! I'll check out the other thread.

I really appreciate this, it makes spaces so much better!

1 Like

Okay, you can download it and others here. Macros included:

  • New Brave Window Here
  • New Chrome Window Here
  • New Finder Window Here
  • New Safari Window Here

Global Macro Group Macros.kmmacros (25 KB)

Note that the four macro above call a subroutine named sub—Position/Resize Front Window. That subroutine is included in this thread: SUBROUTINE: Vertical Alignment of Windows Using Percentages—SCREEN, SCREENVISIBLE, MENUBARHEIGHT - Macro Library - Keyboard Maestro Discourse

I love that you found those edge cases with the window location. I do keep my dock on the right and can never keep it from overlapping just slightly. Now I know why!

At first blush, I thought Ventura Stage Manager might supersede Desktop Spaces; but to the contrary, it seems the two work together quite nicely: An In-Depth Look at macOS Ventura Stage Manager


2023-03-13 Update: macMac has an newer Stage Manager video: The Comprehensive Guide To Mac Stage Manager. If you want to give Stage Manager a try, I recommend watching both videos.

@_jims Have you upgraded to Ventura?

I did last week and now the "move window n space" macros aren't working.

I can move spaces with Cntl-arrow, or with Cntrl-Cmd # -- but the move window scripts reposition the arrow, then change spaces, but the window doesn't move.

Any troubleshooting thoughts? I'm on MacOS 13.0, and KM version 10.2

Hi @blfarris; yes I have. I'm currently using 13.1 Beta (22C5033e) with Intel Macs. Are you using an M1?

I've not seen this problem, but I have tweaked a few of the subroutines and have been testing them for several weeks.

It could be related to and embedded AppleScript, but that's only an educated guess based on other issues I've seen with Ventura.

Later this week I'll send you a DM with a few updated subroutines. I'm confident that we'll be able to get this resolved.

OK, I just restarted the computer and it seems to be working fine now ¯_(ツ)_/¯

Naming Desktop Spaces

Note: This is not exactly on-topic for Jim's macro set, the primary topic of this thread. But it is, I believe, relevant to the larger topic of how to manage Desktop Workspaces effectively, in this case by using names instead of numbers. So this is, perhaps, a discussion of a future feature of Jim's macros, one which some people want but which he hasn't been able to implement.

Hi Nick,

I, too, used to use Stickies, they just seemed conceptually like the right thing, but Apple's Stickies really don't do the job -- if you have to reboot the Stickies will all open back up on the first Desktop, which is not what you want.

I was working on KBM macros to attempt to reposition each Sticky onto the right Desktop (I was stuck on how to identify each Desktop where there wasn't already a sticky there -- I could do it manually but it took a while). Then I found the free app CurrentKey (also called CurrentKey Stats because the author focussed a lot of features on collecting and displaying statistics on how much time you spent in each app on each Desktop). CK does the job wonderfully (except that I would like names longer than 16 characters, but that's a quibble).

CurrentKey even lets you assign hotkeys to each desktop. And, like Stickies, when you rearrange the order of the Desktops, the names move too, so the names stay with the content. Numbers, like in Apple's Mission Control or Jim's system here, don't do that, which is why I will avoid numbers for anything. I could not remember whether my KBM desktop was 15, 16, or 17, etc., especially not when I rearranged the desktops to keep the ones I am currently working on together, which is a hugely useful feature of Desktops that I didn't want to give up.

Based on my own experience, I believe the limitation of numbers is one of the prime reasons that Desktop Workspaces hasn't been more popular.

For me, I have over 20 Desktops, so it was pretty impossible to find hotkeys in any consistent pattern with letter mnemnonics for the content of each desktop, which didn't also accidentally typo into inadvertent things like closing all windows of the current app without saving.

So I made a KBM menu system front end to CK that took care of that. One hotkey brings up the Desktop names menu and a second keystroke, just a mnemonic letter, chooses the Desktop to go to. (I've posted the macro for how to automatically get a Return after the single keystroke to choose the Desktop from KBM's Prompt With List menu.) I can rearrange the order of the Desktops and even rename them on the fly and the system keeps up automatically.

I started writing a tutorial of how to set up this whole thing that was hoping to promote as a way to actually get Desktop Workspaces to fulfill the promise they have hinted at for over a decade (and maybe turn some of the people complaining on various Apple forums on to KBM). And then, unfortunately, the author of Current Key, Spencer Daily, withdrew it from the App Store because he lacks the time and resources to support the latest versions of MacOS (and because he recently became a father).

Right now, the only way to get CurrentKey is to follow Spencer Daily on Twitter. Every few months or so he announces that he will make Current Key available briefly on the App Store, or you can ask him to do so and when there are a few people in the queue he'll make it available for a couple of days.

So my tutorial languishes because I really don't want to promote a method that relies on an App that is no longer available. What's the point in that? Instead I have started working on ways to duplicate the Desktop Management features of Current Key (I don't care about the statistics). Whether it will integrate with Jim's system here, I don't know yet. As I've mentioned, key requirements for me are:

  • Long names (there's an old app out there that allows you to assign names to Desktops of up to three letters, but it patches Mission Control so you have to turn off System Integrity Protection to install it)
  • Rearrange Desktops and have the names follow (Stickies does this)
  • Change names on the fly (don't have to dig into code just to change a Desktop name)
  • Mnemonic menu access that doesn't care about renaming
  • Scales to my 20+ Workspaces

The big limitation for me of Jim's system, even with his extension to it described in Workspaces in Mission Control Desktop Spaces - Questions & Suggestions - Keyboard Maestro Discourse, is that both the Desktop Workspace names and Desktop order have to be hardcoded in KBM macros, you can't change them on the fly to suit what you're working on without having to dig into the KBM macro definitions.

As you have perhaps discovered with Stickies, you can change the name of a Desktop by changing the text of the Sticky, and when you rearrange the order of the Desktops, the Stickies follow along so there's nothing to update.

I had a correspondence with Spencer Daily after he withdrew CurrentKey and he told me that the core of the Desktop Space management was that he created invisible/hidden app windows on each Desktop, where the title of the window was the name of the space. So, just like you do with Stickies, bringing the appropriate window to the fore automatically changes the Workspace, without having to hack Mission Control.

In my current work-in-progress, I'm not worried about hiding the app windows. Instead I'm trying to allow there to be windows from a variety of apps, e.g., Notes, TextEdit, Typora. The key to whether an app can be used the way I want is whether, unlike Stickies, if the system shuts down, it restarts with the app windows on the right desktops, so the desktops can keep their names.

It's a complicated system, I'm not a professional software engineer, and I don't have a lot of time to devote to it, but I'm making progress.

Let me know if you're interested.

1 Like

Hi @August. It's not that I haven’t been able, it's that I have never tried; and as I replied to @nickwild above, I have no plans to add this capability.

For my workflow, this is not a limitation. Using the OP macros, I'm able to easily move windows to/from any of my 16 Desktop Spaces (regardless of space number/proximity), thus I have no need to rearrange the spaces. In fact, since I have a history of ergo pain from mouse overuse, I create macros that leverage the keyboard. Space rearrangement incudes mouse gymnastics that are particularly unappealing to me.


@August, based on this post and several of your others, it's clear that you have a different workflow with respect to spaces. I think it safe to say that this macro set will never be a helpful tool for you. But as we all know, the real beauty of Keyboard Maestro is that custom automations can be purpose-built and it seems that you are making good progress doing just that.

Dear community,
I'm using this macro in Ventura. I've 2 Desktops but when I try to move then window to a different desktop it says that the Desktop doesn't exist. It's valid between 1 to 2 and vice-versa.

I'm not a programmer and it's difficult to me to analyse this.

Any idea why this is happening?

BS

Hi, @bsilvamm. I'm the one that created and shared this macro set. It works fine with Ventura; in fact I'm using the latest beta: Ventura beta 13.3 (22E5219e).

I suggest you go to the top of this thread and scroll down to the Installation section. If any of the steps are skipped, the macros will not work as expected.

After confirming your set-up, please report back. If you are still having difficulty I'll do my best to help you troubleshoot further.

Hi @_jims
Thanks for your quick reply!

I've done all the steps (I think) and the same error occurred. The 2nd desktop is an external screen, could it be the issue?

BS

Yes, It should be related to the the external display. I've created another space in macbook display and it works fine.

I don't have an external display, so unfortunately I won't be able to test your configuration. However, if you give me two bits of information, I might be able to help:

1. Keyboard Shortcuts Settings

Please share a screenshot of your Keyboard Shortcuts for Mission Control. Here's are mine (Ventura System Settings):

2. WhichSpace Indication

When you are using the Desktop Space on your external monitor, what number is indicated by WhichSpace in the mac menubar? Likewise, when you switch spaces on your MacBook, what numbers are indicated?