🔥 Automation Overload - Example of running macOS Monterey Shortcuts via Script Kit

Install macos-monterey-shortcuts-example

/** @type {import("@johnlindquist/kit")} */
// Menu: Say Hello World Shortcut
// Description: Trigger macOS Monterey Shortcut from Script Kit
// Author: James Henry
// Twitter: @MrJamesHenry
/**
* I have created a Shortcut on my Mac running macOS Monterey called
* "Say Hello World".
*
* There are a couple of options available when it comes to invoking
* it programmatically (whether via Script Kit or in general).
*/
/**
* OPTION 1:
*
* You can use the `shortcuts` CLI that is preinstalled on macOS
* Monterey to run named Shortcuts.
*/
await $`shortcuts run "Say Hello World"`;
/**
* OPTION 2:
*
* You can use AppleScript to communicate with the "Shortcuts"
* application on macOS Monterey to run named Shortcuts.
*
* NOTE: I first tried to communicate with "Shortcuts Events" per this
* video from WWDC 2021, but it does not work:
* https://developer.apple.com/videos/play/wwdc2021/10232/?time=1539
*/
await applescript(`
tell application "Shortcuts"
run the shortcut named "Say Hello World"
end tell
`);