Various Methods for Displaying KM Variables and Data

Hey Neil,

Great idea.

Here's my take:

Insert "Display Variable..." Action v1.01.kmmacros (14 KB)

Macro-Image

Keyboard Maestro Export

2 Likes

Stealing shamelessly from @noisneil and @ccstone, I'll contribute my spin...


PURPOSE

Used during macro editing, this macro will add a group action to display a macro variable. The specific group action added depends on the the state of the shift key (⇧) when the macro is triggered:

⇧ up : Display Text (in window)

⇧ dwn: Prompt for User Input

The first form (⇧ up) is useful in a target macro when one prefers to display the value of a variable but immediately continue macro execution.

The second form (⇧ up down) is useful in a target macro when one prefers to pause a macro and view the value of a variable. After reviewing, the macro can be resumed or canceled.

Note that the text cursor must be properly placed before this macro is triggered. For example, with the Set Variable to Text action or the Set Variable to Calculation action, the text cursor must be placed in the first field of the action, i.e., the field labeled Set variable.

Once the text cursor is properly placed and this macro is triggered, it will insert the new group action immediately below the action that includes the cursor. The inserted group can then be optionally moved manually.

MACRO SETUP

Before triggering this macro for the first time, complete the SETUP STEPS detailed within the macro.

ACKNOWLEDGEMENTS

In a Keyboard Maestro forum thread started by @Sleepy, Various Methods for Displaying KM Variables and Data, @noisneil first suggested this clever technique; @ccstone subsequently contributed his take on the idea. This macro builds off the ideas from both.

TESTED WITH

• Keyboard Maestro v10.2
• Ventura Version 13.0 Beta (22A5342f)/MacBookPro16,1
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445

VERSION HISTORY

1.0 - Initial version

1.1 - Changed the Title of the groups to use [Debug] in the name.

1.2
a) Changed name from Insert ⇨****Actions to Display a Macro Variable to Insert Actions to Display a Macro Variable.
b) Changed hot key triggers and changed alternate modifier from ⌥ to ⇧.
c) Removed insered tabs before Display Text dialog
d) Change the vertical bar to a consistent unicode character (⏐).

2.0
a) Added an alternate output format that works better if a variable is a text list. This format is inserted if the trigger includes ⌥.
b) For Display Text action, change unicode character (⏐) to [ and ]. This is consistent with syntax used in Augment or Filter Text.


DOWNLOAD Macro File:
Insert⇨Actions to Display a Macro Variable.kmmacros (38 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Macro-image

2 Likes

@ccstone Much neater way of adding the variable name. Lovely stuff. What's the purpose of deleting the past clipboard? Is it intended to retrieve whatever was previously copied? I ask because I copy to the clipboard in tons of macros and never add this at the end; maybe I should!

@_jims I like the prompt idea! Very clever! I like the icon too. I watched the new Batman film the other day, so I took the liberty...

?.png.zip (119.3 KB)

image

1 Like

Yes, this is a good thing to do so that your latest clipboard entry is whatever it was before the Macro started. For this purpose I have made a Favorite Action called "Clean Up System Clipboard" to put at the end of my Macros which looks like this (the default deletes the past two clipboards but easy to change the number once inserted to delete however many are needed to get back to previous state).

image

2 Likes

Good to know. I've made one and added a disabled pause action before the clipboard delete, to remind me that a pause might be necessary. This is because I just added your action to some macros whose final step is a paste, and they failed to function because the clipboard was deleted before the paste completed. Just something to be aware of.

2 Likes

Yes, good idea.

@Sleepy just adding my voice to the choir of thanks! This will come very handy!

I'm currently in fresh OSX install hell...

I've set up KM, and now I find that my Display Variable macro isn't working because it moves on before the Insert Text by Typing action has finished. Does anyone know of a way to ensure that the next action doesn't interrupt typing? I can set a pause of course, but it would be nice to know if there's a way that doesn't rely on set times.

Hi @noisneil - looks like the original version that you have at the link above inserts the text by pasting rather than typing and you do have a pause after it.

1 Like

Ah yeah. Good catch. Think I changed it so I could avoid having to clean the clipboard. This is something I've come across before though so if you do know of a way to wait until typing is done, so let me know. :+1:t3:

My humble contribution. Pasting is faster than typing but you have to clean up the clipboard, so I made a "subroutine" to do it all. (Started out before subroutines were truly supported, so this is kind of a hybrid)

1 Like

I've modified Insert⇨Actions to Display a Macro Variable to Version 2.0. See above for details.

These are great suggestions and tips for newbies like myself. Thanks for sharing these. To share my own process, I like to utilize the log action liberally as I develop my macros. This has the added benefit of being able to follow along with the progress as it is running for long tasks. I put together a start debug macro that I call at the top of my more complex macros that opens the KM engine log file in the Mac console app and then clears the console display.

Macro Screenshot

Keyboard Maestro - Start Debug.kmmacros (7.4 KB)

1 Like

Here's the approach I've been using for some time, which includes the two Display Variable actions mentioned in this thread. It creates the actions by pasting their xml (rather than using Favourites), so it's a little slicker to use and requires no setup.

2 Likes

I’ve created a new macro that supersedes Insert⇨Actions to Display a Macro Variable.

2 Likes

This looks great! The only issue I have is that I don't have physical Fn keys, so I'd need to change the triggers, and that seems like quite an undertaking. I may take the time to look into doing that in the next few days. Excited to give it a go!

1 Like

Just in case this is the old "MacBook Pro with Touchbar" limitation -- holding down the Fn key should get you F1 through F12 in the Touchbar, and I'm assuming those still work with modifiers keys...

Not as handy as "real" keys, but would let you try @_jims's macro to see if it's worth changing the triggers to suit your preferences.

2 Likes

I did have a try and the Touchbar keys aren't great with multiple taps. I'll persevere though!

2 Likes

Hi, @noisneil. I created and use this on my 16" MBPro (Intel) with a Touch Bar and have no problems invoking multiple taps. Note that you can hold down Fn as you multiple tap F2.

2 Likes

Note that I've updated the aforementioned macro, Insert Action to Check Variable(s), to Version 3.2.

1 Like