Pro-Tip: Shortcuts Has Its Own Suite of AppleScript Commands

I utilize AppleScript to trigger my Shortcuts via Stream Deck every day โ€“ so I wanted to document the command suite on the open web.

Many people donโ€™t know that the Shortcuts app can be automated on the Mac using its dedicated scripting dictionary.

This requires a bit of meta thinking, but that means both the application itself and all the shortcuts contained within it are available to control remotely via AppleScript and applications like Script Editor โ€“ as well as triggered via devices like the Stream Deck, which I use every day at my Mac mini.

In order to make these methodologies more accessible, I wanted to share instructions here on how to access the AppleScript dictionary for Shortcuts, plus share a copy of the commands so everything is freely available on the web.

Hereโ€™s how to access Shortcutsโ€™ scripting dictionary:

  1. Open the Script Editor app
  2. In the Menu Bar, select File > Open Dictionary (or press Command + Shift + O)
  3. Browse through the dictionaries until you find Shortcutsโ€™ (or type โ€œShortcutsโ€ on the keyboard to navigate there directly), then open the Dictionary.
  4. There, youโ€™ll see Standard Suite and Shortcuts Suite; under Shortcuts Suite, youโ€™ll find the โ€œClasses and Commands for working with Shortcuts.โ€

For reference, hereโ€™s what is documented in the command set:

Shortcuts Suite

Classes and Commands for working with Shortcuts


applicationโ€‚n [see also Standard Suite]

ELEMENTS

contains shortcuts, folders.

—-
shortcutโ€‚n : a shortcut in the Shortcuts application

ELEMENTS

contained by application, folders.


PROPERTIES

name (text, r/o) : the name of the shortcut

subtitle (text, r/o) : the shortcut’s subtitle

id (text, r/o) : the unique identifier of the shortcut

folder (folder) : the folder containing this shortcut

color (RGB color, r/o) : the shortcut’s color

icon (TIFF image, r/o) : the shortcut’s icon

accepts input (boolean, r/o) : indicates whether or not the shortcut accepts input data

action count (integer, r/o) : the number of actions in the shortcut


RESPONDS TO

run.

—-

folderโ€‚n : a folder containing shortcuts

ELEMENTS

contains shortcuts; contained by application.

PROPERTIES

name (text) : the name of the folder

id (text, r/o) : the unique identifier of the folder

—-

runโ€‚v : Run a shortcut. To run a shortcut in the background, without opening the Shortcuts app, tell ‘Shortcuts Events’ instead of ‘Shortcuts’.

run shortcut : the shortcut to run

[with input any] : the input to provide to the shortcut

โ†’ any : the result of the shortcut

—-

To keep this post as reference material, Iโ€™ll share methods for utilizing these AppleScript commands here on my blog using my AppleScript tag.

To learn more about scripting, check out Appleโ€™s documentation for Navigating a Script Dictionary โ€“ thatโ€™s part of the now-archived Mac Automation Scripting Guide which provides more insight into how Script Editor and AppleScript can be used across macOS.

Posts You Might Like

Automators: Vision Pro Automation ยป
Automator hosts Rosemary Orchard and David Sparks talked in detail about the Shortcuts and automation experience of the Apple Vision Pro โ€“ excellent episode.
Automatically switch to a different app every time you open Twitter ยป
Jay Robinson shared this great Automation idea for building better social networking habits โ€“ automatically switch to a different app when you use a particular network.
Automating with Shortcuts and macOS Folder Actions ยป
Jason Snell shared a classic automation post covering how to use long-living Mac feature combined with the latest Shortcuts features.
Use This Automation To Protect Your iPhone If Stolen While Unlocked
Diego Jimenez has put together a clever shortcut for securing your iPhone using the Lock Screen action that works as a Personal Automation when Airplane Mode is activated.