MACRO: Variable Inspector Prompt and Dictionary Editor v2.0.2

Variable Inspector Prompt and Dictionary Editor v2.0.2

REQUIRES Keyboard Maestro version 10 and above

See "Version History" below for, well, a history of the versions.

(NOTE: The prompt is resizable, but I wanted to keep the images small-ish.)

PURPOSE

The Variable Inspector Prompt is a new and incredibly useful way to view, edit and delete your variables from inside a running macro, including Local and Instance variables, Global variables, and Dictionaries. (See above image.)

You can also run it in an advanced mode to show all your global variables, which is really useful for cleaning things up. You can select a variable, click a button, and have the Keyboard Maestro Editor search for that variable:

 
You can even sort the variables by size, so you can focus on eliminating the ones causing the most clutter:

 
FEATURES

Honestly, there are almost too many features to list them all here. But here's some of them:

  • NEW! Full-featured Dictionary Editor.
  • As mentioned above, sort by size.
  • Copy the selected variable name(s) to the clipboard, with or without their contents.
  • Edit and delete variables and dictionaries.
  • Unlimited Undo and Redo.
  • View "pretty" JSON.
  • Enable/Disable word wrap, and fixed/proportional fonts.
  • Reload the variables without closing the prompt (in some situations).
  • Popup tooltips.
 
USAGE

Just insert a special action group in your macro, where you want to pause the macro and inspect the variables. Something like this:

image

 
A. Enter "1" in this field to take advantaged of KM 10's new %AccessedVariables%, to automatically show all variables your macro's accessed up to this point

B. Enter more variable names if you want, separated by commas, or "all" to inspect all global variables.

C. Enter dictionary names you want to see, separated by commas, or "all" to see them all.

When the macro gets to this point, it pauses while the prompt is displayed. Inspect or edit the variables, then click "OK" to continue with your macro, or "Cancel" to abort.

But how do I insert the action group into my macro?

The easiest way is to use KM 10's new Favorite Actions feature, or my KMFAM macro set. You could also used a named clipboard. Or just plain old copy/paste.

 
VERSION HISTORY

v2.0 - Added a full-featured Dictionary Editor.

v2.0.2 - Fixed a display/scrolling bug that occurred with large Dictionaries.
v2.0.1 - Fixed a bug in handling some shortcut keys.

v1.0 (and minor versions) - Initial Release.

 
INSTALLATION

UPGRADE INSTRUCTIONS:

  1. Delete the old macros, or just delete the entire group.
  2. Install the new macros.

Download the macros, unzip them, and double-click the .kmmacros file. It will import these macros:

image

 
I added prefix order numbers to each maco, so you could tell where to start. After you've become comfortable with the macros, you can remove the order numbers and the separators, if you want. Personally, I'm leaving them as is.

VIP - Variable Inspector Prompt v2.0.2.kmmacros.zip (66.2 KB)

12 Likes

I don't know how you do it Dan, but this is amazing.

I barely finished reading your post and installing the macros and already I'm thinking of so many use cases, especially when building and debugging macros.

This needs to be put in the best macro list.

-Chris

Thanks. I have to laugh - this started out as a relatively simple idea. Then I kept saying "Hey, I bet I could add ..." I had to stop and post the dang thing, or I'd never stop!

But boy was it fun. I did a lot of things I'd never done in HTML/CSS before.

I am nowhere near your level (and never will be) of programming, but I can relate in my own way to this sentiment :sweat_smile:

A question: running your "Inspect All Global Variables & Dictionaries" macro does not show all of the variables that my KM preferences pane shows. From a cursory inspection it appears that certain variables that are empty show up in the preferences pane but do not show up in the macro. Is this by design? Not a big deal either way...

No debug variables here...:point_down:

Debug variables (and others, all empty) do show up here... :point_down:

Hey Dan,

Holy Smokes! You've done it again...

:sunglasses:

-Chris

4 Likes

:grinning_face_with_smiling_eyes:

Regarding the variables, I've noticed some inconsistencies there too. I think they're variables that have been set to "%Delete%", but I'm not sure. If we really care, we can ask Peter, but as long as it's only missing variables with empty values, I figure it's no big deal.

And for anyone who cares, I'm not using "document.kmvar" to get the names of all the variables, because KM might exclude some of the larger variables from that list.

So before I launch the prompt, I ask the KM Engine for the names of all the variables. When the prompt runs, it gets that list of variable names, and then uses window.KeyboardMaestro.GetVariable to get the values of each variable.

No biggie. That makes sense because that's what I do with global variables I no longer need at the end of a macro.

I'll post a more detailed question for Peter in a while.

1 Like

Excellent Dan! Again!! Thanks very much

1 Like

Just uploaded version 2.0, which includes a full-featured Dictionary Editor. You can download it from the first post.

I'll appreciate any feedback you might want to share. Thanks!

2 Likes

Just uploaded version 2.0.1, which fixes a bug in handling some keyboard shortcuts.

1 Like

Thanks for this Dan, as always. But I think I've mentioned before how no good deed ever goes unpunished..

I'm seeing some issues with scrolling the panes. Everything works well until I view a dictionary with a lot of entries in the grid view. Then both panes freeze and will not scroll.

Changing the entry pane to JSON restores scrolling to both panes, but changing back to grid freeze them again.

More..

When I enlarge the window so that I can see the entire dictionary (and the Reload & Done) buttons, the variable list can scroll again. Reduce the window size (and lose the bottom of the list and the Reload & Done buttons) the variable pane continues to scroll but the dictionary values will not.

Sorry to be the bearer!

Don't be - I want the feedback. But this one has be stumped a little. I tested it with a dictionary with 1,000 entries, and it still scrolls fine.

Wait, the bottom buttons disappear? They shouldn't move at all with the scrolling - they should be stationary at the bottom of the window. Like this:

What OS version are you using?

I am possibly the entire staff of your Monterey Q&A department Chief!

Well, the good news is (I suppose) that I can recreate the issue in my Monterey Parallels virtual machine. WTF is wrong with it, I don't know, but I'll see what I can figure out.

Delete the macro "40)[VIP] Setup Variable Inspector Prompt - Advanced (Subroutine)".

Then install this:

40)[VIP] Setup Variable Inspector Prompt - Advanced (Subroutine).kmmacros.zip (50.7 KB)

Test it, and let me know if it fixed this problem.

I don't doubt you'll find other problems, and in fact I'm trying to hunt down some odd behavior on my machine, but one thing at a time.

It's late and loud here Dan, but I did a quick test and this DOES seem to fix all of the problems I encountered.

Thanks very much (as usual)! And I'll let you know if I enconter any other issues.

Good to hear. I have no idea how I managed to guess the solution, but at least it works. And not only that, it fixed the other problem I was trying to hunt down. Two birds with one stone. Not bad, for a WAG (wild-ass-guess). :grinning_face_with_smiling_eyes:

2 Likes

New version 2.0.2, available in the first post.

Fixes a display/scrolling bug with large dictionaries. If you don't have any of those, you can skip this version if you want.

2 Likes

Hey Dan, I've finally had a chance to actually use your macro set beyond a cursory inspection and it's amazing as usual.

I have however seen what may be a bug... the reload button doesn’t appear to do anything.

While I was recording this, I was toggling my microphone, so this muteStatus variable should have been changing back and forth between Disabled and Enabled.

Is it a bug or is it simply a PEBCAK? :sweat_smile:

VIP Reload button glitch