MACRO: Insert Action to Check Accessed Variables, v1.1

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:

  1. ⌘: Display variables for the selected action(s) or all actions above
  2. : Display variables and pause or display and continue.
  3. ⇧: 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 [ :red_circle: Display Variables ] Groups? (Select One)

  • Disable (This Group)
  • Disable (This and Subsequent Groups)
  • :heavy_check_mark:︎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
  • :heavy_check_mark:︎Permit Control By An Above Group

Selected Actions Only? (Select One)

  • :heavy_check_mark:︎Selected Only
  • All Above This Group

Exclude Unchanged Variables? (Select One)

  • :heavy_check_mark:︎Exclude
  • Include

Exclude Empty Variables? (Select One)

  • :heavy_check_mark:︎Exclude
  • Include

Exclusions (comma separated RegEx patterns specifying variables to exclude)

  • :heavy_check_mark:︎Reset Button

Optional Window Title

  • :heavy_check_mark:︎:red_circle: Display Variables - # -, where # is a counter

The checkmarks (:heavy_check_mark:︎) 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

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-Image


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


OPTIONAL MAIN MENU

4 Likes

Example use of Insert Action to Check Accessed Variables.


The macro below originally had the top four actions. With all four selected, or just the fourth, the Teal group is added using the primary hot key trigger [ ⌃F3 ] of Insert Action to Check Accessed Variables.


When the above macro is run (with the four actions selected), the following is generated by the Teal group.


The behavior of the Teal group can be optionally modified by expanding it and changing the included options.

Keyboard Maestro Export

2 Likes