Shortcuts for Mac: Scripting your desktop with Apple’s Mac-only actions

Hero image of a shortcut on the Mac showing the Windows actions.
(Image credit: Future)

When Apple brought Shortcuts to the Mac in macOS Monterey, the initial set of actions available that take advantage of Mac features were ported over from Automator.

These actions were previously available (in a similar form) in Automator for users building workflows to automate their tasks — with Shortcuts for Mac, those same functions were recreated as native actions, largely located in the Scripting category.

This piece explains how to best automate your favorite Mac with Shortcuts actions for controlling your apps, changing window arrangements, and adding advanced functionality using the Script Editor app actions:


Inside the “Apps” section of the Scripting category in Shortcuts for Mac, users will find two actions — Hide App and Quit App — in addition to the existing Open App and Split Screen Apps.

(Image credit: Future)

“Hide App” can be used to hide all windows from any app you choose, all your apps, or, when used multiple times, a set of apps. Alternatively, the All Apps option also allows an “Except” field where you leave multiple specific apps open. In effect, “Hide All Apps Except” works as “Show Only These Apps,” an interesting use case for focusing on a specific task.

Once an app is hidden, its windows will remain hidden until you click on the app icon or switch to the app using the App Switcher, at which point the windows will reappear.

(Image credit: Future)

“Quit App” goes all the way to closing the application, including similar options to choose one app, quit all apps, add exceptions, and quit multiple apps if added to a shortcut multiple times.

Quit App also includes a Show More button that, when expanded, reveals a toggle for “Ask to Save Changes,” which can show the system prompt for any relevant documents or files that need saving. If Ask to Save Changes is toggled off, any unsaved changes will be lost, so only use this if you need to force all apps to quit.


In the Windows section of the Scripting category, Shortcuts for Mac users will also find actions for Find Windows, Move Window, and Resize Window.

(Image credit: Future)

Find Windows is used to retrieve the current set of windows open on your Mac, pulling them into your shortcut to subsequently be used to Move and Resize the windows. Find Windows includes the ability to add Filters, where you can then find windows by the Title, App Name, Width, Height, X Position, Y Position, and Window Index. Plus, you can use Sort By to rearrange windows using those same values, and a Limit option is available if you wanted to perhaps sort by window index and only get one to grab the top-most window for example.

This means you can, in effect, search by the title shown at the top of any window, find windows from a specific app, only grab windows within or beyond a certain size, look for windows in specific locations on your screen, and even check for the top-most window or another one below it in the stack.

Once you’ve added some filters and tested which windows appear based on your current setup, you can then pass that new “Windows” variable into the Resize Windows and Move Windows actions as needed to re-organize your setup. 

(Image credit: Future)

The Move Windows action lets you place any window into a set of nine default positions on your screen — from top, middle, and bottom, to left, center, and right. Alternatively, a Dimensions field is available, which then lets you enter variables for X and Y coordinates, and the values you enter will adjust the location starting from the top-left corner of your screen.

Move Windows also includes a “Bring to Front” toggle that lets you put the specified window on top of everything else, or otherwise leave it at its present index in the window stack.

(Image credit: Future)

Similar, the Resize Windows includes nine positions and a Dimensions option for specifying your own Width x Height — the positions are Fit Screen, Top Half, Bottom Half, Left Half, Right Half, Top Left Quarter, Top Right Quarter, Bottom Left Quarter, and Bottom Right Quarter. Resize Windows also includes a “Bring to Front” toggle.

Script Editor

In addition to scripting the Apps and Windows on your Mac, Shortcuts also provides actions for the Script Editor app, the native tool Apple provides for creating and running scripts using AppleScript or JavaScript for Automation.

(Image credit: Future)

Both the Run AppleScript and Run JavaScript for Automation actions include the ability to accept input, specify parameters for that script, and return the input at the end. Both actions also include a comment for “Your script goes here”, where users familiar with AppleScript or JavaScript for Automation can place their scripts to execute when run.

Each action also includes a “Build” button (in the form of a hammer icon) that validates the script contents once they’re filled out, making sure there aren’t any errors in the code so you can properly debug it without actually running the full script.

These Script Editor actions are a great utility for more advanced Mac users and people familiar with the existing scripting tools on the platform; Apple originally launched these as a holdover from Automator as Shortcuts for Mac is part of a multi-year transition as the “future of automation.”

For now, these actions let Shortcuts act as a good front-end to the scripts that existing Mac users have already built — the Menu Bar in particular makes these super easy to access. And in theory, in the future, Shortcuts should be able to solve these same use cases using native actions, if that “future of automation” quote becomes the “present” of automation.

For that reason, the best way to take advantage of Run AppleScript and Run JavaScript for Automation actions (for users not already familiar with those programming languages) is to find good examples online and replicate them in your shortcuts, or build off scripts using existing foundations.

(Image credit: Future)

One area I’ve found fun to play with is this list of AppleScript key codes from blogger Christopher Kielty, who has documented all of the ways to use AppleScript to simulate pressing keys on your keyboard.

Using the example codes linked on the page for specific keys — as well as modifier keys — Shortcuts users can in effect “press” keyboard shortcuts and activate commands from their Mac apps that are not otherwise able to be automated yet.

(Image credit: Future)

(Image credit: Future)

Here’s an example shortcut “File > New” that simulates Command + N, the widely-used shortcut for creating a new item in relevant Mac apps. This second shortcut, “Hide Others,” uses the Command + Option + H keys to replicate the “Hide All Apps Except” function of the Hide App action — use it as an example for pressing multiple modifiers at once.

Making Mac more efficient

Shortcuts for Mac’s new Scripting actions for Apps and Windows let Mac users build shortcuts that perfectly rearrange their desktop setup — they can open the exact apps they want, with the windows in the right place and size, plus hide anything that doesn’t need to be visible just yet.

And as you might notice, the ability to run scripts of any type using Shortcuts for Mac greatly expands the possible capabilities of what you can do once those apps are open — until Shortcuts and Mac apps develop more native actions for these kind of functionalities, Shortcuts users can always try to script the Mac itself to accomplish the same goals.

Shortcuts for Mac still has further opportunity for automation — including updated Files actions and Finder tools, plus actions for Archives, Disk Utility, and Network drives — plus the whole host of App Store apps that provide Shortcuts actions for their own functions, so the platform still has room to grow beyond these Automator-based actions.

But the Mac as a place for deep productivity combined with proper support for automation tools from Apple is an exciting place in 2022 — I look forward to seeing how Apple brings that future of automation into the present first-hand.

Matthew Cassinelli

Matthew Cassinelli is a writer, podcaster, video producer, and Shortcuts creator. After working on the Workflow app before it was acquired by Apple and turned into Shortcuts, Matthew now shares about how to use Shortcuts and how to get things done with Apple technology.

On his personal website, Matthew has shared hundreds & hundreds of shortcuts that anyone can download, plus runs a membership program for more advanced Shortcuts users. He also publishes a weekly newsletter called “What’s New in Shortcuts.”