Use Case
- AFAIK, KM does NOT provide a direct means of determining when a Macro is called via a Execute a Macro action, aka a "Sub-Macro"
- So if a Macro could be used directly (i.e. executed by a trigger), OR it could be used as a Sub-Macro, how can we tell how it is being used?
- After some limited testing, it appears to me that:
IF a Macro is triggered directly, THEN:
- The %ExecutingMacro% token will be the SAME as the %ExecutingThisMacro% token.
- The %TriggerValue% will be based on the actual trigger
ELSE IF a Macro is Called via "Execute Macro" Action, aka "Sub-Macro", THEN:
- The %ExecutingMacro% token will be DIFFERENT from the %ExecutingThisMacro% token.
- The %TriggerValue% will be the PARAMETER as entered on the Execute Macro Action.
@peternlewis, would you please confirm or correct this assertion?
Assuming this is correct, here is a Macro that shows how to use this information.
It is a Macro that can be used in either mode (Direct or Sub-Macro).
Example Output
Trigger Tokens When Used as a Sub-Macro
Trigger Tokens When Used Directly (Triggered by a HotKey)
MACRO: Trigger Tokens in a Sub-Macro (called by Execute Macro)
VER: 1.0 2020-01-05
Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
DOWNLOAD Macro File:
Trigger Tokens in a Sub-Macro (called by Execute Macro).kmmacros (11.2 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.
MACRO: MAIN Macro to Call Sub-Macro To Get Trigger Info [Example]
VER: 1.0 2020-01-05
Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
DOWNLOAD Macro File:
MAIN Macro to Call Sub-Macro To Get Trigger Info [Example].kmmacros (3.7 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.