Wow @Sleepy this is a really well written tutorial. I shudder to think how long it took you to write it up. Thanks for sharing!
Thanks for the compliments, friends. I wrote it up in one sitting. I can't remember how long it took, but it was pretty fast.
Don't forget my Variable Inspector Prompt.
Sorry for forgetting. I can probably append that when I get back from my imminent appointment.
I don't know if anyone's already posted anything similar, but I've found this handy.
Setup: Save a Display Text in Window action to your favourites if you haven't already. Change the purple action in this macro to select it from the Menu.
Use: Click in an action's variable field then trigger this macro. It will insert the Display Text in Window below the currently selected action, with the variable entered for you.
Here's my take:
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.
Before triggering this macro for the first time, complete the SETUP STEPS detailed within the macro.
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.
• 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
1.0 - Initial version
1.1 - Changed the Title of the groups to use [Debug] in the name.
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 (⏐).
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.
@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)
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).
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.
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.
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.
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)
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.
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.
I’ve created a new macro that supersedes Insert⇨Actions to Display a Macro Variable.