AppleScript process tokens with some Macro Information tokens

Testing inside KM 7.0.2 (as Execute Text AppleScript action) these tokens

tell application "Keyboard Maestro Engine"
  set v1 to process tokens "%TriggerBase%"
  set v2 to process tokens "%TriggerValue%"
  set v3 to process tokens "%ExecutingMacro%"
  set v4 to process tokens "%ExecutingMacroGroup%"
  set v5 to process tokens "%ExecutingMacroUUID%"
end tell
v1 & " " & v2 & " " & v3 & " " & v4  & " " & v5

seem broken… at least on my OS X 10.10 Yosemite system.

Hopefully others tokens are OK.

Any idea about the reason?

– Alain

Hey Alain,

These are not really broken, they're just not available from AppleScript. (The AppleScript action doesn't see the Keyboard Maestro context.)

If you want to get those tokens INTO AppleScript you'll need to assign Keyboard Maestro variables to the tokens and then get the values of the variables into AppleScript.

In the macro below I'm doing this en mass, but you can do it piecemeal if you wish.


Set Variable var to Text.kmmacros (2.4 KB)


And there does seem to be a direct route (KM 10), if we furnish the instance code. A subsequent addition, perhaps ?

e.g. for %HTMLResult% after a Custom HTML Prompt interaction, for example, (and writing in the JS idiom of osascript):

Application("Keyboard Maestro Engine")
    .processTokens("%HTMLResult%", {
        instance: ObjC.unwrap(

or in AppleScript:

use framework "Foundation"

tell current application
    set instanceCode to (its (NSProcessInfo's processInfo's ¬
        environment's objectForKey:("KMINSTANCE"))) as text
end tell

if missing value is not instanceCode then
    tell application "Keyboard Maestro Engine"
        process tokens "%HTMLResult%" instance instanceCode
    end tell
end if