QUICK START
- Select an action within another macro.
- Press the primary hot key [ ⌃F3 ] for this macro. A group of actions will be inserted below the selected macro action.
- In the other macro, select one or more actions above the inserted group.
- Run the other macro.
- When the other macro executes the inserted group, a window will be displayed that includes the values for variables within the selected actions.
PURPOSE
Used during macro development and simple debugging, when triggered, this macro will add a macro group that includes actions that will display macro variables values (per the %AccessedVariables% token and various specified options).
The macro has eight different triggers that are all combinations of three options:
- ⌘: Display variables for the selected action(s) or all actions above
- ⌥: Display variables and pause or display and continue.
- ⇧: Insert the group below or above the selected action(s).
If display and pause is selected, a dialog will be displayed with three buttons:
1. Continue : the %AccessedVariables% window will remain open and the macro will continue; can be specified by pressing the return key.
2. Close Window and Continue : the %AccessedVariables% window will be closed and the macro will continue; can be specified by pressing the c key.
3. Cancel : the macro exits; can be specified using the esc key.
The primary trigger for this macro is ⌃F3. It, or any of the other seven, can be tapped once, twice, or thrice. If tapped once, a Display Text action will be inserted below the selected action(s).
Mode 2: If ⌃F3 is tapped twice, the previously used trigger (one of the eight) will be effectively repeated. This provides a quick method to insert several identical groups.
Mode 3: If ⌃F3 is tapped thrice, a Prompt With List menu will be displayed with the eight options selectable:
⌃F3 : Insert Below; Display Variables and Pause; Selected
⌃⌘F3 : Insert Below; Display Variables and Pause; All
⌃⌥F3 : Insert Below; Display Variables and Continue; Selected
⌃⌥⌘F3 : Insert Below; Display Variables and Continue; All
⌃⇧F3 : Insert Above; Display Variables and Pause; Selected
⌃⇧⌘F3 : Insert Above; Display Variables and Pause; All
⌃⌥⇧F3 : Insert Above; Display Variables and Continue; Selected
⌃⌥⇧⌘F3 : Insert Above; Display Variables and Continue; All
When the PWL menu is rendered, each option will be labeled with the corresponding trigger. This provides a quick reference to the eight options.
GROUP OPTIONS
As stated above, this macro inserts a group of actions that has options to display macro variables. Two of the options selected|all and pause|continue are set based on the trigger used to execute this macro. All of the options can be changed after the group is inserted. The options are as follows:
Control [ Display Variables ] Groups? (Select One)
- Disable (This Group)
- Disable (This and Subsequent Groups)
-
︎Display Variables and Pause (This Group)
- Display Variables and Pause (This and Subsequent Groups)
- Display Variables and Continue (This Group)
- Display Variables and Continue (This and Subsequesnt Groups)
Independent Control? (Select One)
- Independent
-
︎Permit Control By An Above Group
Selected Actions Only? (Select One)
-
︎Selected Only
- All Above This Group
Exclude Unchanged Variables? (Select One)
-
︎Exclude
- Include
Exclude Empty Variables? (Select One)
-
︎Exclude
- Include
Exclusions (comma separated RegEx patterns specifying variables to exclude)
-
︎Reset Button
Optional Window Title
-
︎:red_circle: Display Variables - # -, where # is a counter
The checkmarks (︎) above indicate the options that are set if the group is inserted using the primary hot key for this macro [ ⌃F3 ].
MACRO SETTING
local_VariableCharacterCountThreshold : 55 [default]
If an accessed variables value is one line and less than local_VariableCharacterCountThreshold characters, then the variable will be displayed as follows:
⭕️ local_A [%Variable%local_A%]
If an accessed variables value is one line and greater than or equal to local_VariableCharacterCountThreshold characters, then the variable will be displayed as follows:
⭕️ local_B
[%Variable%local_B%]
If an accessed variables value is more than one line, then the variable will be displayed as follows:
⭕️ local_C
%Variable%local_C%
CALLING THIS MACRO
If this macro is called from another macro and a Parameter of 2 or 3 is specified, this macro will run in Mode 2 (use Previous Option) or Mode 3 (display PWL Menu of Options), respectively. This provides a method to run the macro in the alternative modes without using the two- and three-tap methods described above.
RELATED INFORMATION & ACKNOWLEDGEMENTS
-
Thanks to @noisneil for feedback and testing prior to the release of this macro. He suggested the method used to present and select the options within the group.
-
The multi-tap detection is done using the amazing HotKey Multi-Press Template, by @DanThomas.
-
Insert Action to Check Accessed Variables largely supersedes a macro I previously created and shared, Insert Action to Check Variable(s); it creates the variable list by parsing the XML of the actions that are selected when the macro is invoked. In most respects, this macro is superior, but Insert Action to Check Variable(s) might be of some value to those with interest in this topic.
-
When inspecting variables within a macro, another very useful macro is Variable Inspector Prompt and Dictionary Editor, by @DanThomas.
-
For full-featured debugging of macros, I recommend: Checkpoint System: An Additional Way to Debug in KM, by @tiffle.
TESTED WITH
• Keyboard Maestro 10.2
• Ventura 13.3.1 (22E261)/MacBookPro16,1
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445
VERSION HISTORY
1.0 - Initial version
1.1 - Fixed a few typographical errors in this header and in the macro group that is inserted.
Download: Insert Action to Check Accessed Variables.kmmacros (708 KB)
Macro-Notes
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
System Information
- macOS 13.3.1 (22E261)
- Keyboard Maestro v10.2