Zabobon's Dynamic Workspaces v6.01

If you can wait a few days, I'm working on a new version of this. Some of the interface will be different and better - so, might be worth waiting a bit for that version :grinning:

Having said that, the new version will be backwards compatible with any data saved by the current version. The main change will be ability to save as many different Workspaces as you want, rather than limiting the number.

(The thing that takes the longest with uploading a Macro here, is checking and rechecking for bugs and writing the ReadMe file of Instructions..!)

2 Likes

Too late. I already tried it. Love it.

Some feedback that you've probably already considered, all delivered with the caveat that I have no idea how difficult or time consuming they might be to implement, so please forgive me if I'm casually asking you to move mountains:

  1. Currently, adding the active folder to the most recent set involves three keypresses. (Activate macro, enter, then enter again.) Consider adding another hotkey option that would add the active folder without having to interact with the save folder dialog.

  2. Currently, the macro only saves the active folder, regardless of how many other tabs are open in the active window. It would be incredible if there was an option to save all open folders, or all open tabs in the active window. (My test of the macro involved individually saving a few dozen Finder tabs, easily ~100 keypresses; doing that in one or two would be killer. I understand that the current limit on set size may be an / the obstacle.)

  3. The save folder to set dialog defaults to the most recent set, with the option to use the dropdown menu to select a different destination. Currently, changing the destination works but the set contents list doesn't update.

  4. It would be nice to have the option of restoring a set to its own new window. I would probably set that as my default behavior.

  5. Have you considered expanding the macro to the workspace-level? Meaning save/restore for all open Finder windows, keeping track of which tabs are associated with which window. Bonus points for also remembering window position on screen.

On the chance you haven't already seen it, you might want to check out this thread. One of the scripts in the linked thread reliably retrieves the path of every open Finder tab other than searches:

tell application "Finder"
   set winList to windows
   repeat with theWin in winList
      try -- Filter-out any search windows and convert to aliases.
         set contents of theWin to (target of theWin as alias)
      on error
         set contents of theWin to 0
      end try
   end repeat
end tell

# Finish filtering
set winList to aliases of winList

Regardless of whether any of my suggestions are implemented, this absolutely rocks. Thanks again.

Glad you like it!

Of course, it's set up for my use rather than for all possible uses - but I think it's pretty flexible. And the great thing about Keyboard Maestro Macros is that you can edit them yourself and get something totally bespoke to what you want.

To save a window to the currently selected Workspace should be:

  1. Click on the window to select it
  2. Press the key combination โŒƒโŒ˜S
  3. Hit Return

(The confirmation window goes on its own after a few seconds so, you don't have to close it.)

And if you ever move a Window in a Workspace to a better position you just repeat that and its new position overwrites the old positon.

You only have to save the Window positions once. After that, restoring the Workspace is really quick.

only saves the active folder, regardless of how many other tabs are open in the active window.

In my case I never use Finder Tabs - I'm just too old and ingrained in my ways, having separate Finder Windows open as I like to drag things from Window to Window. But with a bit of tinkering I'm sure you could adapt it.

For my use, I wanted to save several Finder Folders, a few Application Window positions and any single Webpage that was open (usually a particular shared Google Sheet).

Most of the Macro is taken up with the Prompts - and trying to make the process clear. The actual saving of the Data is relatively simple. It makes use of Keyboard Maestro Dictionaries where the "key" is whatever you call the Workspace.

Anyway, the next version will have a few refinements and I'll have a good read through your list to see if I can incorporate any of your ideas! :grinning:

1 Like

Just a heads up: the one time I tried restoring a workspace with all slots full the restore was fast enough that I couldn't tell what was going on with the progress bar. All I saw was a line of vertical rectangles. (I actually assumed that you were using a font I hadn't installed :stuck_out_tongue:)

I found it was useful to have a "progress bar" for the times when the restore was taking a little time (for example if Final Cut was having to be opened, which can take a long time). It lets me know stuff is happening and that the Macro is working (and keeps my hands from typing stuff while the Windows are restored). It is "simple" in the sense that it just uses native Keyboard Maestro Actions rather than a Custom HTML - and I can understand how it works so, I can maintain it!

The sub-macro "Progress Bar" gets called each time one of the Slots in a Workspace has been restored. And this sub-macro is being called Asynchronously - meaning it isn't slowing the main Macro down. As I wanted to indicate the progress with a simple text string I used ๐Ÿ€† and ๐Ÿ€ซ symbols to indicate progress - ๐Ÿ€†๐Ÿ€ซ๐Ÿ€ซ๐Ÿ€ซ๐Ÿ€ซ๐Ÿ€ซ๐Ÿ€ซ ๐Ÿ€†๐Ÿ€†๐Ÿ€†๐Ÿ€†๐Ÿ€ซ๐Ÿ€ซ๐Ÿ€ซ ๐Ÿ€†๐Ÿ€†๐Ÿ€†๐Ÿ€†๐Ÿ€†๐Ÿ€†๐Ÿ€ซ which are built into the standard Mac fonts. These symbols could be easily replaced by anything you want (even emojis) by editing the series of Actions in the Progress Bar Macro.

click to show image

image

For example, you could have a series of :green_circle: :green_circle: :green_circle: :green_circle: :white_circle: :white_circle: to indicate progress.

3 Likes

Hi!

thank you for this amazing macro. Personally, this is one of my favorite macros so far. The only issue which I'm experiencing is hang-ups when I add Safari or Chrome to the mix. For example, I have 6 apps in 1 workspace. Everything works well until KB tried to open Safari or Chrome window. It just hangs and I can see a moving KB icon in the menu bar and I have to cancel the macro manually. Hitting Control-Command-R second time ( or more ) make just thing worse ( rainbow wheel ).

I'm using KB Version 9.2 and macOS 11.5.1 on two machines. Both of them, same issue. Sometimes Safari windows appear but it's blank without a URL and it ignores the saved position on the screen.

From your description, I assume you can open and store multiple Safari / Chrome windows ( same as Finder ). Here again, Finder works, Safari doesn't.

Thank you for any suggestions.

Hi @roskozmos
Iโ€™m travelling at the moment but will endeavour to answer your questions properly once Iโ€™m back home (in a couple of days).

With this one - no, it only stores one Safari and one Chrome per Workspace. Iโ€™ll look into whether that is easy to change. Iโ€™m sure itโ€™s possible.

Also, Iโ€™ve done a major overhaul of the whole Macro and will be uploading it soon. It will be able to store an unlimited number of Workspaces rather than limited to the 12 of the current version. Iโ€™ve also tried to streamline the Interface.

1 Like

Thanks for the clarification with Safari / Chrome windows. Also, I notice, when you save the same app to multiple workspaces and combine your macro with Mission Control, these apps keep opening on previously used Spaces (Desktops). But I'm willing to ditch Mission Control in favor of having this satisfying feeling of pixel-perfect windows on the screen each time with just the press of a button.

speaking about buttons... Is it possible to assign shortcuts to each workspace? Your macro is too complex and it's easy to get lost (at least for me). I have a small MIDI controller on my desk. Would be awesome to trigger workspaces with these MPC pads.

thanks again for your work and happy traveling!

UPDATE: Latest version 2.89 uploaded to replace the link at the head of this thread.

โ€ข Changed to allow an unlimited number of Workspaces.
โ€ข Changed to allow saving of multiple Safari or Chrome Webpages in each Workspace.
โ€ข Added Macro, "Workspaces Options..."
โ€ข Tried to simplify the interface, whilst adding more options.
โ€ข Reworked the Progress Bar to stop it vanishing and reappearing in a long Restore.

That's done for this version. But it might mean you have to manually recreate your existing Workspaces.

I couldn't recreate this. However the new version saves and restores Safari and Chrome Windows in a different way so hopefully works for you. Just one thought - it could have been the Macro taking a long time to reach a certain web address - in the new version the Progress Bar waits for each Window to be restored before moving on so, that might give a better indication of what is happening.

That was a bit of a limitation with the way Dropdown Lists work in Keyboard Maestro. I've changed the way this works in this version so that the lists always update.

I implemented this but decided it added an extra layer of complication. If you want to do this it can be done by making dedicated new Macros, each with their own shortcut keys, that set the Workspace to the one you want and then Restore their Windows. But I found that in use I never remembered which Workspace had which shortcut so it was actually quicker to just run the Restore Workspace Macro and choose the Workspace to Restore from the list.

1 Like

Hello @Zabobon ,

thanks for the update! I like the new interface changes and the ability to create even more Workspaces. Progress Bar seems to work more reliably. Unfortunately, my previous issue with Safari / Chrome windows persists.

I was messing with the interface, deleted Workspace E by mistake then was unable to change the order alphabetically ( Workspace E was last in the list ). Long story short: I deleted something else and now the interface looks a bit broken.

I tried to delete the macro group, then import it again with no success. The Macro is still broken. That makes me wondering. Maybe my problem with your macro is still there, sitting somewhere in the Application Support folder I guess, so I'm still experiencing the same issues no matter which version I'm using.

I found here on the forum that all macros are stored in "Keyboard Maestro Macros.plist" I don't want to mess with that at least I have to. Do you know what else I can try to completely delete your macro?

I did try "Revert Macros" in the "File" menu, but the problem persists.

Thank you for any suggestions.

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