THIS WEEK'S SPONSOR:

Daylite

Take Your Business Out Of The Dark With Daylite


How to Batch Convert Shortcuts for Use Throughout Monterey and with Other Automation Apps

My latest Shortcuts experiments began in earnest on my way back from Rome. I stopped in Ireland for a few days to deal with COVID testing and start ramping back up to my normal work routine. I wasn’t quite ready to tackle the day-to-day yet, so I decided to revisit a Shortcuts experiment I had started back in June.

I’ve been a fan of PopClip for years and have played around with creating my own extensions for the app occasionally. So, shortly after WWDC, I tried building a PopClip extension that triggered a shortcut that had been saved as a Service. PopClip works with services, and the extension I built came tantalizingly close to working, but it had too many issues to be useful, so I set it aside.

PopClip.

PopClip.

Sitting in Dublin with the released version of Monterey and a new version of PopClip that had been updated to work with Shortcuts, I revisited my early experiments. The updates to macOS and PopClip made adding shortcuts as PopClip extensions trivially easy, as Federico demonstrated recently in MacStories Weekly. Then, when I got home, my Stream Deck was waiting for me, which led to another round of experimentation and an in-depth story on the many ways it can run shortcuts.

Since then, I’ve been incorporating Mac shortcuts I’ve built into my workflows using multiple third-party apps like BetterTouchTool, Alfred, and, of course, PopClip. It wasn’t long before I wished there was a way to batch process shortcuts, so I could use them in multiple ways across Monterey and in third-party apps.

Scripts built with AppleScript are just one way to integrate shortcuts with other apps.

Scripts built with AppleScript are just one way to integrate shortcuts with other apps.

To streamline the process, I turned, of course, to Shortcuts itself. In total, I’ve created four shortcuts to help me deploy my favorite shortcuts across macOS:

  • Script Builder: Generates .scpt files that can be incorporated in other apps from multiple shortcuts using AppleScript
  • Dock Applet Builder: Creates Dock applets from shortcuts that can be launched from the Finder, app launchers, and more
  • Script Applet Builder: Converts shortcuts into AppleScript applets with custom icons that behave like Dock applets but don’t get automatically deposited in your Dock
  • PopClip Builder: Produces and streamlines installation of multiple PopClip extensions with custom icons that run shortcuts

I’ll cover the first two shortcuts here. Script Applet Builder and PopClip Extension Builder are included in The Macintosh Desktop Experience, my column for ClubMacStories+ that explores new ways to make your Mac work for you.

Script Builder

I built Script Builder to make it easier to move many of my existing shortcuts to the Stream Deck, but its utility is broader than that. Shortcuts can be triggered using AppleScript using a simple script in this format I covered in my Stream Deck story:

tell application "Shortcuts Events"
    run the shortcut named "Hello World"
end tell

The first solution I came across for running shortcuts via AppleScript on the Stream Deck was a third-party plug-in. I wasn’t satisfied with that solution, though, because it requires the script to be pasted into the Stream Deck app, locking it away in the plug-in where it’s not easy to access from other apps. That’s why I created Script Builder.

Because the AppleScript syntax is so simple, you don’t really need Script Builder for generating one-off scripts. Just open Script Editor, paste in the code above and replace ‘Hello World’ with the name of your shortcut. I’ve done that plenty myself and then saved the script as a .scpt file.

Scripts built with Script Builder.

Scripts built with Script Builder.

The advantage of using a .scpt file is it can be used by multiple apps. You can drag the file into an ‘Open’ action in the Stream Deck app and run it with the press of a button. Then, you can point Keyboard Maestro at the same file and trigger your shortcut from that app too. It’s a more flexible solution than locking the script in a plug-in.

However, it didn’t take long before building one-off scripts felt like a chore, which is why I created Script Builder. Now, as I go through my library of shortcuts and think about how I can use them on the Mac, I can batch process them into .scpt files. Here’s how.

Picking shortcuts to convert to <code>.scpt</code> files.

Picking shortcuts to convert to .scpt files.

Script Builder takes advantage of the fact that AppleScript is plain text. First, the shortcut displays a list of all of your shortcuts, allowing you to pick multiple shortcuts. Second, Script Builder iterates over each shortcut you’ve selected, dropping its name into an AppleScript template that includes a placeholder for the shortcut’s name. A separate Text action combines the shortcut’s name and .scpt to create a file name. Then, the resulting .scpt file is saved to the Script Editor folder in iCloud Drive. When every shortcut you’ve picked has been processed, Script Builder exits the repeat loop and opens the Script Editor folder in iCloud Drive, so it’s easy to access them for adding to Stream Deck buttons or incorporating into other apps.

The result of Scrpt Builder is a folder of <code>.scpt</code> files that can be used in other automation apps or with devices like the Stream Deck.

The result of Scrpt Builder is a folder of .scpt files that can be used in other automation apps or with devices like the Stream Deck.

Script Builder is a good example of a straightforward utility shortcut that has streamlined a repetitive workflow. It didn’t take a lot of time to build, but it has significantly sped up the process of making my shortcuts available to other apps using AppleScript.

You can download Script Builder here and from the MacStories Shortcuts Archive.

Script Builder

Script Builder, a shortcut made by MacStories.net’s John Voorhees, allows users to convert multiple shortcuts into AppleScript .scpt files.

Get the shortcut here.

Dock Applet Builder

Dock applets are another alternative I described in my Stream Deck story. From the Shortcuts app’s File menu, you can choose ‘Add to Dock’ to create a Dock applet that sits in your Dock and is saved to the Applications folder inside your user folder.

The File menu's Add to Dock' command.

The File menu’s Add to Dock’ command.

The advantage of Dock applets is that they automatically adopt the same icon you picked for them in the Shortcuts app, and they act as mini-apps that can be launched with apps like Alfred and LaunchBar even if you drag them out of the Dock. You can also move Shortcuts Dock applets to your main Applications folder, the Desktop, or wherever else you’d like. As mini-apps, Dock applets can be run from other automation apps like BetterTouchTool or Keyboard Maestro too.

As with the scripts I’ve been using with Shortcuts for Mac, I wanted a faster way to create Dock applets. The difficulty with Dock applets is that they can only be created from the Shortcuts File menu and the shortcut for which you’re creating an applet has to be selected or open.

The first step was to visit the Shortcuts section of the Keyboard panel inside System Preferences. Click the plus button beneath the list of App Shortcuts, pick the Shortcuts app and add a keyboard shortcut for the ‘Add to Dock’ menu option, which will allow you to automate the creation of Dock applets. It’s necessary to use the exact format for the Menu Title field for this to work properly.

The Dock Applet Builder shortcut begins the same as Script Builder, allowing you to pick multiple shortcuts. Next, the shortcut iterates over each shortcut, opening them with the Open Shortcut action, using BetterTouchTool to invoke the ‘Add to Dock’ keyboard shortcut you created in System Preferences, and then using BetterTouchTool again to close each shortcut’s window.

Dock applets are saved in a different Applications folder than the one you're probably used to using.

Dock applets are saved in a different Applications folder than the one you’re probably used to using.

I’d rather not have to open each shortcut file to generate its Dock applet, but it’s the only reliable way I’ve found to automate the process. Fortunately, the windows can be just as easily closed after each shortcut is processed, avoiding a deep stack of windows. Also, although keyboard shortcuts can be scripted with AppleScript, that method causes an error in Shortcuts, which is why I used BetterTouchTool’s ‘Send Keyboard Shortcut’ action.

The biggest downside to generating multiple Dock applets is that each one is deposited in your Dock. I’d prefer if including an applet in the Dock was optional, but it’s not, which means dragging the applets out of the Dock if you don’t want them there. Still, Dock applets are one of the most versatile options for running shortcuts, so if you have a bunch you want to access that way, Dock Applet Builder will make quick work of the process.

I don’t have an iCloud link for Dock Applet Builder to share yet due to some issues Apple seems to be having with the Shortcuts Gallery and/or shortcuts signing at the moment. Fortunately, Dock Applet Builder is short, so I’ve included a full screenshot below and will update this story and the MacStories Shortcuts Archive with links when I can generate them.


The flexibility of Shortcuts on the Mac is something we’ll be exploring more on MacStories in the coming months. What I like most about creating scripts and applets to run shortcuts is that it enables users to work with shortcuts using any app that supports AppleScript or launching apps, such as Keyboard Maestro and Alfred, even if they don’t directly support shortcuts yet. I hope that direct integration will come because tighter integration will open up new possibilities for Shortcuts on the Mac. Even if it doesn’t, though, there are plenty of options already available and worth exploring.

To learn how to build applets with custom icons that work like Dock applets but aren’t deposited in your Dock and batch-create PopClip extensions for your shortcuts with custom icons, be sure to check out my Macintosh Desktop Experience column, which is available for Club MacStories+ and Club Premier members here. To learn more about Club MacStories and sign up, visit plus.club.

Unlock MacStories Extras

Club MacStories offers exclusive access to extra MacStories content, delivered every week; it’s also a way to support us directly.

Club MacStories will help you discover the best apps for your devices and get the most out of your iPhone, iPad, and Mac. It’ll also give you access to advanced iOS shortcuts, tips and tricks, and lots more.

Starting at $5/month, with an annual option available.

Join the Club.

A Club MacStories membership includes:

  • MacStories Weekly newsletter, delivered every week on Friday with app collections, tips, iOS workflows, and more;
  • MacStories Unplugged podcast, published monthly with discussions on what we’re working on and more;
  • Monthly Log newsletter, delivered once every month with behind-the-scenes stories, app notes, personal journals, and more;
  • Access to occasional giveaways, discounts, and free downloads.