Applescript syntax for passing search string to "Trigger Macro by Name"

I want to pass an "Initial search" string to "Trigger Macro by Name" from Applescript, but the following script is not doing it:

tell application "Keyboard Maestro Engine"
    do script "Trigger Macro by Name" with parameter "a:safari"
end tell

Please let me know how to do this.

The Trigger Macro by Name action needs to include the %TriggerValue% token in its initial search for this to work:

image

But that also includes the hotkey you use to trigger the macro manually:

Is there a reason this needs to work from AppleScript? Could you make a separate "Trigger Macro by Name" macro configured with "a:safari" in the macro itself?

image

@gglick Thanks for showing that %TriggerValue% in the Macro search field receives the passed parameter. I didn't think of the script parameter as a Trigger.
I do have specific searches already filled out like you showed, but I wanted to use AppleScript to analyze the window and document in some apps and restrict the search choices accordingly without cluttering up KM with many variations of the search Macro.
For instance, different commands for Javascript docs vs. Applescript docs in Script Editor.

1 Like