Zabobon's Dynamic Workspaces v6.01

Hi @roskozmos

As long as you only deleted things using the interface (i.e. without opening up Keyboard Maestro and deleting parts of the Macros) all you would have done is delete the data that was being stored. Even if you deleted parts of the actual Macros in Keyboard Maestro you would only have broken the Macro itself and nothing else in Keyboard Maestro.

But it is a good chance to explain how the Macro stores the data and hopefully reassure you that all can easily be fixed :blush:

As you probably know Keyboard Maestro can store bits of text data in what it calls "Variables". So, if I want to store something (like the coordinates of a Window, which is four numbers - left, top, width, height) that can be done by storing those four numbers in four "Variables". And then, when I want to retrieve that data (to restore the Window position) I can call on those Variables. I think of these Variables like little user-generated files (a bit like the way Photoshop saves and retrieves user-generated image files).

For this Group of Macros I needed to store data for each Workspace and each of its 8 Windows and Safari/Chrome Webpages etc etc and for this task I used Keyboard Maestro's "Dictionaries" which are a kind of fancy variable. Again, these Dictionaries are designed to be user-generated and edited (from within Keyboard Maestro Macros).

It is worth pointing out that none of these files or any other Keyboard Maestro should ever be edited outside of Keyboard Maestro or a Macro. Do not ever go hunting around in the Finder.

From what you have said, I think the worst you can have done is either mess up my Macro (by deleting parts of it from within Keyboard Maestro - which doesn't sound like what you've done) or mess up your saved Workspaces data (by deleting from within the Macro's interface).

That will definitely fix things if you have deleted parts of the Macro itself.

But the "data" is not stored in the Macros. It is stored as lots of numbers, in the Variables and Dictionaries and they persist.

(Again, a bit like the way uninstalling and reinstalling Photoshop would not change any of the image files it had generated).

It sounds like all you have done is delete some of your Workspaces or the saved window positions in those Workspaces.

What I would do is open up my Options Macro and choose Clear Slots. Then choose the Workspace that you think you broke and Clear All its slots. Then position the windows again and resave them using the Save To Macro.

As I mention in the Notes, even deleting a Workspace name doesn't actually delete its data. It just hides the name from the list of Workspaces. So, if you wanted to change the order of the Workspaces in the list (you said you wanted them to be alphabetical) it is perfectly okay to delete all the Workspaces one by one (using the ⌫ Space option) and then type them in again one by one (using the + Workspace option). Needless to say, doing all this from the Macro interface - not by going into Keyboard Maestro itself.

And in case you are worried that these "Dictionaries" and "Variables" persist - they are the tiniest amount of data - just lists of numbers in text format. But as it is not good practice to have data hanging around that is not needed, these Macros automatically clear any data that is not needed by using "Local" and "Instance" Variables wherever possible (these only persist while the Macros are running and clear themselves out at the end of each run).

Having said all that - I will test this myself over the next days (by trying to mess things up deliberately) just to make sure it works solidly. If I find a problem, I'll upload a new version.

I actually deleted "unnamed workspace" which is last on the list.

Click to Show Image

Mac mini 2021-08-25 o 10.40.53

and after that interface looks like this

Click to Show Image

MacBook Pro 2021-08-25 o 11.22.28

Now, it seems I fixed it by recreating all Workspaces from A to L and I can see this "unnamed workspace" again on the last position. I just have to recreate my window positions again, which is ok for me.

On my second machine at work, I tried again Safari/Chrome. When macro launches one of these apps, it just stops working. When Safari/Chrome IS NOT running, then the first Safari/Chrome window will open - ignoring the saved website. If I have multiple Safari/Chrome windows in the same Workspace, just the first one works. The progress bar is still on the screen but after few minutes of waiting, I just Cancel All Macros from the menu bar.

When Safari/Chrome IS running ( without open windows ) then not even the first window will open. Macro successfully opens other apps but hangs on the slot with Safari/Chrome.

Don't know if this description can help you understand what's going on but at least I fixed the problem with the interface while writing this reply :smile:

Ah, that's very interesting and thanks for taking the time to work it out! That extra blank Workspace is a result of the list of saved Workspaces having an extra "|" at the end. The list builds up as you add more Workspaces, each separated by a "|" like:

Workspace A|Workspace B|Another Workspace|

As you add more Workspaces I had them added to the list with their name and a "|". So, adding a New Workspace would make the list:

Workspace A|Workspace B|Another Workspace|Yet Another Workspace|

To stop that extra blank Workspace being created I need make sure the list doesn't end with a "|" but should be:

Workspace A|Workspace B|Another Workspace|Yet Another Workspace

I knew that as part of my system for adding Workspaces there would always be an extra blank one at the end of the list but never realised it could cause a problem. I think it's easy to fix so I will fix that.

By the way, the generic Workspaces A, B, C etc were only meant to be a starting point. I would suggest giving your Workspaces more useful names like "Zoom Meeting" "Editing Review" based on the work they are associated with and get rid of the generic A,B,C ones.

I'm still not able to recreate this on any of my Macs (I have tried it on 4) so, I'm really not sure what is going on or why your system is different to mine. As a test I tried just adding a load of Safari and Chrome Windows and they all open really quick.

click to show image

image

That is of almost zero help to you. But it shows that it can work as expected. Just a hunch, but Mac OS Big Sur can deny Keyboard Maestro certain permissions to do things (like controlling specific Apps). When Keyboard Maestro first tries to do something in Safari or Mail a dialog can pop up asking for you to allow it control it. The problem with solving this kind of stuff is that it could be one of many things and it's hard to find the cause. All I can say is that what this Macro does is very simple and generic so, should just work...
Can you let me know what versions of Keyboard Maestro, Mac OS, Safari and Chrome you have?

Yeah, I've seen that before and allowed this king of pop-up windows. I've also turned on the "Full Access" setting in "Security & Privacy", also as "Accessibility" and "Screen Recording" in System Pref. for KM.

Sure.
Keyboard Maestro Version 9.2
macOS Big Sur Version 11.5.2 (20G95)
Safari Version 14.1.2 (16611.3.10.1.6)
Google Chrome 92.0.4515.159 (x86_64)

Both of my machines have Intel CPU.

sorry for stupid question but where I can rename workspaces? I remember that in previous versions there was a "Rename" button. But in v2.89 I can't find it. I know I can choose a custom name when adding a new Workspace but can't figure out how to rename existing ones. :man_facepalming:

As the names of the Workspaces are what Keyboard Maestro uses to recall the window there isn’t a “rename” as such. You can make an unlimited number of new ones and delete as many as you want but the window positions are linked to whatever name you originally gave the workspace.

The previous “rename” feature didn’t actually rename it replaced one of the 12 Workspaces with a new one.

But it’s a good point that you should be able to rename and keep the data. I will do that!

In the meantime you could Restore a Workspace, make a new Workspace name and resave each window to the new named Workspace. If I were you I’d keep the A,B,C ones for a couple of days and wait for the update.

This is what’s interesting about uploading a Macro - others will use it slightly differently to me. But that’s also what makes this an interesting thing to do. :grinning:

Thanks for being the Beta tester!

Added in now for latest version 2.96

I'm going to have a look at this and see if I can work out why it works for me and not for you. I might have to ask you to run some test Macros to see if we can pinpoint what is going on.

Could you try this debugging Macro?

TEST Workspaces Safari Window Restore v001.kmmacros (33.4 KB)

It just opens this Keyboard Maestro Forum in Safari and resizes the Window to a dimension. It uses the same procedure as my Restore Macro. But it does it in steps, with a confirmation as each step completes successfully. If you run it and click "Continue" for each step it will either complete successfully or it will fail at a certain point - which might pinpoint what is not working on your system the same as mine. There are some pauses in the Restore (waiting for Safari to be fully open etc) and maybe one of these pauses is causing the macro to hang on your system. Running this test Macro on my Mac restores the Safari Window successfully.

I am beginning to suspect this might be a regional issue as this part of the Macro pauses until certain menu items are available and these Menu Items might be called something slightly different on your system. If that is the issue it will be easy to fix I think.

click to show image

image

Version 3.08 adds a "Help" button with detailed instructions.

Trying to strike a balance between keeping the interface as simple as possible whilst still providing instructions on how to actually use these Macros.

Apart from bug fixes I think I'm done now.

1 Like

This was a regional language issue, that meant the Macro didn't work correctly on Macs set to a System Language other than English. It was because I had used a Menu Item to pause the Macro until Apps were fully open. I'd used "About Safari" "About Google Chrome" etc as the menu item for Keyboard Maestro to look for. But for Macs set to a different language "About" is written as something else. Anyway, fixed in the latest version 3.09 and should run correctly even if the Mac is not set to English.

I can confirm this update finally works for me. Great work!

1 Like

I'm new to KM, and running into a problem getting this dynamic workspace macro to work properly. KM 9.2, Big Sur. I've imported the ZDW macro, and I see it in the list of macros. And if I manually click on 'run', the macro will run. However, what is NOT working is launching it via hotkey. Nothing happens. I even assigned a new hotkey (i.e. command 1), and nothing.

I have successfully created another macro in KM and its hotkey works just fine. So I'm a bit baffled here as to why the default (and custom) hotkeys for ZDW don't run the macros.

Could be a stupid new user issue and probably is....but I can't figure it out. Any help would be greatly appreciated.

Hi @Wolf359SD

When you import a downloaded Macro or Group the Group will come in disabled (for safety reasons). You have to enable the Macro Group for any of its Macros to be triggered by hot keys.

Here are instructions:

https://wiki.keyboardmaestro.com/Macro_Activation

Hello there,

Thanks for the v4.04. I like the new addition "Minimize Other Finder Windows". I'm getting Stream Deck today, would love to see your macros working with Stream Deck. Probably I'll be in touch for the next couple of days :no_mouth:

Have a great day!

I have just discovered this thread and this macro set. I'm excited to try it and unfortunately that may have to wait a couple of weeks or more.

Meanwhile, I'm free-associating on the ideas.

I'm wondering how this workspace concept can be integrated with Mission Control's multiple desktop/workspace concept. I'm an avid user of multiple desktops/workspaces, I currently have 21 in use.

The best way I've found to keep track of them is a tool called CurrentKey Stats, which keeps statistics on which apps you have active in which workspaces, so you can separate Xcode work between Client 1 and Client 2, for instance. CKS allows you to assign names to Mission Controls numbered spaces, and it preserves the names when you rearrange the order of the spaces, where MC renumbers everything. By combining CKS and KBM, my most frequently used hotkey, by far, is the hotkey that takes me back to the previous desktop/workspace. So many different things can pop me over to a different desktop, sometimes intentionally and sometimes not, and being able to return to where I was has been wonderful.

There is also a free utility out there called Clarity that will save the icons on the desktop and let you swap to different sets.
[Link to a previous discussion of Clarity for switching Desktop icons sets.]

1 Like

Hi @August, that's a good question. I plan to dig into @Zabobon's macros to see how I might incorporate them.

For now, I've summarized my approach to your general question in this new thread:

Workspaces in Mission Control Desktop Spaces - Questions & Suggestions

2 Likes

The basis of this Macro Group is fairly simple and uses a combination of Keyboard Maestro's inbuilt Actions to save window coordinates to Dictionaries and then restore those Windows and their coordinates later. In the latest version 5.02 (uploaded 22-04-14 replacing version in the first post) I've started using Keyboard Maestro Subroutines which makes it a lot simpler to work out what the Macros are actually doing (by just looking at the Subroutines).

I've no idea if you could adapt to work with multiple desktops/workspaces as I never use them. But with Keyboard Maestro anything is possible! Or check out @_jims solution which is directly related to what you are looking for I think.

2 Likes

Thanks so much for this!!

Is there an easy way to restore a workspace without the pop up box? Execute the macro to just always restore Workspace A, for example?

Thanks again for all your work putting this together, works like a charm.

Probably the easiest way to do this is:

First duplicate the Macro called "Restore Workspace".

Click to Show Image

Rename that duplicate Macro to something like, "Restore Workspace A". Give it a new hotkey, or whatever other trigger you want to run it. In this example I have given it the hotkey ⌃⌘A

Click to Show Image

Now, in that new Macro:

  1. Disable the Action that is called "Prompt - Execute Until Conditions Met"

  2. And below it add a new Set Variable Action which is set to:

Set Variable Key__Workspace
To Workspace A

Click to Show Image

So, now when you run this new Restore Workspace A Macro it will always restore Workspace A, without any prompt.

(The Prompt was basically asking you to choose a saved Workspace name and it then set the Variable Key Workspace to the name you chose.

1 Like

Darn. I was really excited to try this, but am stuck on an old MacBook Pro and macOS Sierra 10.12.6. :frowning:

Wow, this is great. I've been looking for this. This was it @_jims! Thanks again for the help and referral onto here.

1 Like