Script Trigger %TriggerValue%

Can someone upload a macro that demonstraights this? I am trying to get my head wrapped around all the things that %TriggerValue% can do and this one has me stumped I have tried from multiple angles triggering the macro from another macro returning different values from the AppleScript, running the AppleScript in the macro itself. All i get is empty quotes for what is being returned for the %TriggerValue%.

Also it seems that there is no way to see what is returned for this in the Value Inspector if I am not mistaken. I have just been displaying it larger with
image

https://wiki.keyboardmaestro.com/token/TriggerValue

Also I have no idea what the following means.
"Status Menu or Palette The current modifiers (Note that Option means “edit this macro instead of triggering it”)."

That should show what was used to trigger the macro:

Here I've triggered my web search macro, after adding the Display Text action, and you can see the trigger display in the text window. (This also works when set to "Display text large," but that leads to a messier screen shot :).

It really shouldn't be blank.

-rob.

Thank you for the reply. I have been able to get the option to show for a hotkey trigger but not for anything returned from an AppleScript.

Script trigger Although not technically a trigger, when a Macro is executed via AppleScript the %TriggerValue% token will contain the passed parameter.

Are you saying you're triggering a macro with an AppleScript, and that's returning nothing in %TriggerValue% when you add a Display Text action to the triggered macro?

-rob.

I think the "Script Trigger" entry is talking about KMEngine's "do script".

Try this:

Make a macro with a display in window %TriggerValue%

Make sure it is selected in the Editor

Go to Script Editor. Paste, save and run this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set currentMacroID to ""
tell application id "com.stairways.keyboardmaestro.editor"
	try
		set currentMacroID to id of (item 1 of (selected macros as list))
	on error
		display dialog "please select a macro in the Keyboard Maestro Editor"
		return ""
	end try
end tell


tell application id "com.stairways.keyboardmaestro.engine"
	do script currentMacroID with parameter "do script sez, \"Sender:\"" & (POSIX path of (path to me))
end tell

Your macro should display: "do script sez, Sender: file path to your AppleScript

Can you explain what you mean by "anything returned from an AppleScript"?

When you execute a macro via AppleScript the %TriggerValue% token will contain whatever parameter the AS passed to the macro. So for the macro "Display TriggerValue" containing

image

running the script

tell application "Keyboard Maestro Engine"
	do script "Display TriggerValue" with parameter "3"
end tell

will result in

image

1 Like

Correct. I am triggering it from another macro and tried triggering it from itself (which of course could be a feedback loop).

That's it, thanks!

Yes that AppleScript did it and I was trying to do something simiar but to no avail.
Example(s) - Skillet Macros (v11.0.3)

TriggerValue AppleScript Working (48 KB)