I've been triggering KM Macros via Alfred using simple AppleScript workflows, and that has been working fine.
I am trying to pass a variable to the KM Macro via the AppleScript, but it does not come through.
In Alfred, my AppleScript is:
on alfred_script(q)
-- ignoring application responses
set daycountDisplayType to "large"
tell application "Keyboard Maestro Engine"
do script "E736AF24-E3D1-40BC-A365-6B48D44F1723" with parameter daycountDisplayType
end tell
-- end ignoring
end alfred_script
in my macro, I'm starting by saving the trigger value to a variable, and for debugging purposes, showing that variable as text:
Yes, it's working fine now. BTW, just so I can learn, do you understand what the Variable TriggerValue is, compared to TriggerValue without the variable prefix? I don't quite get it.
The Variable "TriggerValue" is a variable the you have created somewhere.
I find it easier and faster to use the Insert Token by Name. Try it. When the popup menu appears, just type in "trigger".
By the way I’m wondering why you’re using a UUID instead of a macro name. Is this to avoid ambiguity? If so, that’s understandable, but it’s at the expense of clarity.
Weird, I just searched all my macros and I don't see it. So strange!
I just tried it. works like a charm. I guess I don't really understand the difference between a token and a variable. I know a variable can not be a token, but I thought all tokens were by definition variables!
Just to be clear for all readers, somehow you had to have used a Variable with the name of "TriggerValue" in order for it to show up in the Variable list. Maybe it came from an imported Macro.
IAC, here is a screenshot of the "Insert Variable by Name" tool in my KM account, which shows no such variable:
Note that all of the Variables that start with "Local__Trigger" are variables that I created to explore/document the various Trigger tokens.
There is often confusion between KM Tokens and KM Variables.
Please see
The bogus TriggerValue variable either exists somewhere in your macros, or alternatively has a value.
Check the Keyboard Maestro Preferences, Variables, and remove any value from it, and search your macros (All Macros smart group or press Command-F twice) for TriggerValue and look for a macro that is using a variable named TriggerValue.
FWIW, I didn't have TriggerValue in my list of Variables, under preferences. I did have the variable "vorut_Trigger_Value" from this macro I imported a few years ago: MACRO or PLUGIN: Open or Refresh a URL in a Tab (Safari & Chrome)
which has actually not worked right for a few years, so I can delete it anyway.
either way, the real push is for me to read the documentation on the difference between tokens and variables!
To avoid this type of problem, I prefix all of my Global Variables with "DND_" that I want to keep and "Do Not Delete". I then periodically delete all KM Variables except those with the "DND" prefix.
Better still is to always use Local or Instance Variables, which are auto-deleted when the Macro terminates, unless it is absolutely necessary to use a Global Variable.