This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
trigger:Script [2015/07/03 04:36] peternlewis |
trigger:Script [2017/09/04 22:29] peternlewis |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Any active macro can be executed via AppleScript request to the Keyboard Maestro Engine. Keyboard Maestro includes a menu at the bottom of the trigger section showing example code to execute the macro by script in a variety of languages (although all variations break down to AppleScript requests, however that is done within the language). For example: | + | Any active macro can be triggered via AppleScript request to the Keyboard Maestro Engine. Keyboard Maestro includes a menu at the bottom of the trigger section showing example code to execute the macro by script in a variety of languages (although all variations break down to AppleScript requests, however that is done within the language, usually by using the *osascript* tool). For example: |
-- ignoring application responses | -- ignoring application responses | ||
Line 7: | Line 7: | ||
end tell | end tell | ||
-- end ignoring | -- end ignoring | ||
+ | |||
+ | or | ||
+ | |||
+ | osascript -e 'tell app "Keyboard Maestro Engine" to do script "My Example Macro"' | ||
As can be seen, you can execute the macro by name, or more specifically based on the UID of the macro. | As can be seen, you can execute the macro by name, or more specifically based on the UID of the macro. | ||
Line 12: | Line 16: | ||
Note that a macro must be active (that is, it must be enabled, and the macro group that contains it must be enabled and active) in order for the macro to be triggered by any means including via script. | Note that a macro must be active (that is, it must be enabled, and the macro group that contains it must be enabled and active) in order for the macro to be triggered by any means including via script. | ||
- | You can pass a parameter to the macro by adding *with parameter "Whatever"* to the *do script* command (v7.0+). | + | You can pass a parameter to the macro by adding *with parameter "Whatever"* to the *do script* command. The parameter is available to the macro as the [[token:TriggerValue|%TriggerValue% text token]] (v7.0+). |
+ | |||
+ | ===== See Also ===== | ||
+ | |||
+ | === Triggers === | ||
+ | |||
+ | * [[URL|URL]] trigger | ||
+ | * [[Trigger File|Trigger File]] | ||
+ | * [[/Triggers|All Triggers]] |