PURPOSE
This macro opens the most recently executed macro in the Keyboard Maestro Editor.
Alternatively, if triggered using the secondary hot key, the one that includes Shift (⇧), the 14
** most recently executed macros are listed in a Prompt With List.
When the Prompt With List is displayed, the selected macro is opened in the Keyboard Maestro editor. Alternatively, if Shift (⇧) is held down when the macro is selected, the macro is run.
**The default value is 14
because this number of macros vertically fills the Prompt With List menu. The default value can be optionally changed using the local_SecondaryTrigger_NoEntries variable. If the value starts with the plus sign, e.g., +14, the setting, RegexPatterns_MacrosToExclude is ignored.
As noted above, the Prompt With List might exclude macros matching RegexPatterns_MacrosToExclude. In this case, if ⌥<return> is pressed when the Prompt With List is displayed, the Prompt With List reappears with the macros included. Each time ⌥<return> is pressed, the exclusion/inclusion state is toggled.
EXECUTING THIS MACRO FROM ANOTHER MACRO AND/OR BY USING APPLESCRIPT
If this macro is run from another macro using the Execute a Macro action (or via AppleScript), and With Parameter (WP) is specified, the macro runs as follows:
WP | Behavior |
---|---|
1 | the most recently executed macro is opened |
null | the local_SecondaryTrigger_NoEntries number of macros are included in the Prompt With List** |
n | the integer number of macros are included in the Prompt With List** |
+n | the integer number of macros are included in the Prompt With List ignoring the setting local_RegexPatterns_MacrosToExclude** |
**The selected macro can be edited or run.
SETTINGS
local_SecondaryTrigger_NoEntries : refer to the PURPOSE section above.
local_RegexPatterns_MacrosToExclude : can be optionally configured to exclude macros. The value can be one or more text lines, each a regular expression pattern. For example:
^_
[Uu]ntitled
macros that begin with underscore (_
) or include Untitled
or untitled
are excluded. Note that
^%ExecutingThisMacro%$
^%ExecutingMacro%$
are automatically excluded.
ACKNOWLEDGEMENTS
This macro uses JXA shared by @ComplexPoint (N most recently run macros (Name, UUID, Stats)) that extracts data from Keyboard Maestro Macro Stats.plist
. Minor modifications were made to provide compatibility with Keyboard Maestro v10+.
TESTED WITH
• Keyboard Maestro 11.0.3
• Sonoma 14.6.1 (23G93)/MacBookPro18,2
• Sonoma 14.6.1 (23G93)/VariableMacBookPro16,1
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445
VERSION HISTORY
( expand / collapse )
1.0 - initial version
2.0
a) If started from the Keyboard Maestro editor, the setting local_SecondaryTrigger_NoEntries is used.
b) local_SecondaryTrigger_NoEntries can include an integer or a plus sign followed by integer. If the plus sign is included, the setting local_RegexPatterns_MacrosToExclude is ignored.
c) When the Prompt With List appears, depending on local_SecondaryTrigger_NoEntries or the %TriggerValue%, it might exclude macros matching local_RegexPatterns_MacrosToExclude. In this case, if ⌥<return> is pressed when the Prompt With List is displayed, the Prompt With List reappears with the macros included. Each time ⌥<return> is pressed, the exclusion/inclusion state is toggled.
d) Bug fix: If the recently run list included a macro that had been deleted, the macro generated an error. These entries are now properly ignored.
EXAMPLE PROMPT WITH LIST
When using the secondary trigger (or called with a With Parameter), a Prompt With List similar to the following will be displayed.
Depending on local_SecondaryTrigger_NoEntries or the %TriggerValue%, this list might exclude macros matching local_RegexPatterns_MacrosToExclude. In this case, if ⌥<return> is pressed, the Prompt With List reappears with the macros included. Each time ⌥<return> is pressed, the exclusion/inclusion state is toggled.
Edit a Recently Executed Macro Macros.kmmacros (64.3 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 15.0 (24A335)
- Keyboard Maestro v11.0.3