Any way to delete a bunch of unused dictionary values?

I was testing out this macro (the vs.1 version), and ended up with a lot of new "LOCAL_..." variables showing up in the list that I won't be using, and can't remove via accessing the Variables section in preferences. Is there some way to batch remove dictionary values/variables from the variables list (or altogether)?

Please try
Window Information Tools - Macro Library - Keyboard Maestro Discourse

https://forum.keyboardmaestro.com/t/window-information-tools/3824/110

Explanation:

AppleScript and KM measure windows’ bounds differently.

KM uses Width and Height whereas AS uses Distance from the Left and Distance from the top.

Usage: Anytime you need to position 1 or more Finder windows on your screen, first set the relevant windows where you want it/ them - then run the macro and you'll get the AppleScript bounds.

Should you need the bounds for a KM macro where you use "Move and Resize Window" you have to do some math (simple ~).

See this explanation here Copy the AppleScript Bounds Property of the Front Finder Window to the Clipboard

1 Like

Dictionaries are deleted when they are empty. Perhaps the easiest way to do that is:

image

1 Like

Okay great. Looks like I should only have to do this about 80 times for the following dictionaries:

DCT__Application%Variable%LOCAL__Slot%
DCT__Application1
DCT__Application2
DCT__Application3
DCT__Application4
DCT__Application5
DCT__Application6
DCT__Application7
DCT__Application8
DCT__ChromeWebPage1
DCT__ChromeWebPage2
DCT__ChromeWebPage3
DCT__ChromeWebPage4
DCT__ChromeWebPage5
DCT__ChromeWebPage6
DCT__ChromeWebPage7
DCT__ChromeWebPage8
DCT__Height%Variable%LOCAL__Slot%
DCT__Height1
DCT__Height2
DCT__Height3
DCT__Height4
DCT__Height5
DCT__Height6
DCT__Height7
DCT__Height8
DCT__Left%Variable%LOCAL__Slot%
DCT__Left1
DCT__Left2
DCT__Left3
DCT__Left4
DCT__Left5
DCT__Left6
DCT__Left7
DCT__Left8
DCT__SafariWebPage%Variable%LOCAL__Slot%
DCT__SafariWebPage1
DCT__SafariWebPage2
DCT__SafariWebPage3
DCT__SafariWebPage4
DCT__SafariWebPage5
DCT__SafariWebPage6
DCT__SafariWebPage7
DCT__SafariWebPage8
DCT__Top%Variable%LOCAL__Slot%
DCT__Top1
DCT__Top2
DCT__Top3
DCT__Top4
DCT__Top5
DCT__Top6
DCT__Top7
DCT__Top8
DCT__Width%Variable%LOCAL__Slot%
DCT__Width1
DCT__Width2
DCT__Width3
DCT__Width4
DCT__Width5
DCT__Width6
DCT__Width7
DCT__Width8
DCT__WindowName%Variable%LOCAL__Slot%
DCT__WindowName1
DCT__WindowName2
DCT__WindowName3
DCT__WindowName4
DCT__WindowName5
DCT__WindowName6
DCT__WindowName7
DCT__WindowName8
DCT__WindowPath%Variable%LOCAL__Slot%
DCT__WindowPath1
DCT__WindowPath2
DCT__WindowPath3
DCT__WindowPath4
DCT__WindowPath5
DCT__WindowPath6
DCT__WindowPath7
DCT__WindowPath8

These all got created by these "Zabobon's Dynamic Workspaces v5.02" macros that I was testing out but no longer want to use due to the hard limitation of only being able to save something like 8 windows maximum per app for any saved workspace.

I found them all by searching the Keyboard Maestro Macros.kmsync file. I think these are the ones that contain all of the "LOCAL__" variables that keep showing up in the variable name lookup list (⌃⌘v).

I'm guessing the ones like "DCT__WindowName%Variable%LOCAL__Slot%" are just part of the macros to set up the dictionaries, so I probably can skip those.

Actually, after deleting the "Zabobon's Dynamic Workspaces v5.02" macro group, it looks like all the variables associated with it are no longer in the variable lookup list.

If you’re still looking to delete a bunch of dictionaries have a look at this post

2 Likes

General caution: Because you are fixed on KM 9.2 you'll have triage any answers to make sure they don't contain v10-only actions etc... Also worth a review of the "Dictionaries" Wiki page and, since there's some confusion about "local" variables, a look at "Scope" in the "Variables" section of the KM manual would be useful.

As @tiffle's pointed out, you can automate this in KM.

If you mean "in the Variables pane of KM's Preferences" -- Dictionaries don't show up there. But it is easy enough to generate a list:

List Dictionaries.kmmacros (2.9 KB)

Image

You may want to go through the list in a text editor to remove entries for Dictionaries you want to keep, then process your edited list. But I'll take a punt that any Dictionary whose name starts with DCT__ is one of @Zabobon's and:

Delete Zab's Dicts.kmmacros (3.8 KB)

Image

...and you can easily change the "If" action's condition for more precision or a different match string.

2 Likes

Insert Variable by Name... V seems to work this way:
It will list the names of all Variables (Global, Local, Instance) used in any Macro in the Library.
It will also list the name of any Global Variable that is storing a value - even if that Global Variable is no longer used in any Macro.

1 Like

@Nige_S Is there any way to do something similar to hide variables based on the variable name? I am trying to find a way to hide all of the "local" variables in the ⌃⇧V (variable selection) list (also listed under Variable when using the Insert Token dropdown selector, but can't seem to find a way. Using the Set Variable action doesn't seem to work when trying to set the variable to %Delete%, even though the variables have no value, and are only listed in one macro that I've never used.