How to: Use Moom in macOS Shortcuts

Users of macOS Monterey can use the new (to macOS) app Shortcuts to automate many tasks. Developers can add direct support for Shortcuts to their apps, and we’ve heard the requests: We are investigating Shortcuts to see how we can improve support in the next major version of Moom. But just because better support may be coming in the future doesn’t mean you’re locked out of working with Moom in the Shortcuts app right now.

Moom has long supported a basic AppleScript dictionary, and Shortcuts can (with a simple setting change) execute AppleScripts. Once you’ve made that change, you can use Shortcuts to interact with some of Moom’s features. In particular, you can:

  • Activate a saved window layout snapshot.
  • Save a window layout snapshot. You can optionally merge with an existing saved layout snapshot, or replace an existing one (if one exists; if not, it will be created).
  • Center the frontmost window, either using macOS guideline (which is slightly above screen center), or to the exact screen center.
  • Generate a list of saved window layout snapshots.

Here are a few examples to get you started.

Enable Shortcuts’ AppleScript support

The first thing you need to do is allow Shortcuts to execute scripts, including AppleScript. Open Shortcuts’ preferences, select the Advanced tab, and click the first option, Allow Running Scripts:

Once you’ve done that, you’re ready to access some of Moom’s features from Shortcuts. After creating a new blank shortcut, the first step will be the same, regardless of your intended Moom action: Add a Run AppleScript step to your shortcut:

After that, you just need to replace the boilerplate script—all of it—with the Moom action that you’d like to perform in your shortcut.

Restoring a saved window layout snapshot

Use this script to restore a saved window layout snapshot:

tell application "Moom" 
    arrange windows according to snapshot named "Snapshot Name" 
end tell

Replace Snapshot Name with the name of the saved snapshot.

Create a new saved window layout snapshot

Use this script to save a new window layout snapshot:

tell application "Moom"
    save window layout and replace snapshot "Snapshot Name" 
end tell

Replace Snapshot Name with the name you’d like to give to the new snapshot—if it exists, it will be overwritten, otherwise, it will be created. And remember, Moom will just save everything it can see, so you first need to insure the windows are in the locations you want them prior to running the shortcut.

Center the frontmost window

This very simple script will center the fronmost window:

tell application "Moom"
    center frontmost window
    --center frontmost window geometrically
end tell

Notice that there are two choices for centering. If you use the above script as-is, it will center at macOS center, which is slightly above the actual screen center. If you’d rather have the window exactly centered, comment out (or delete) the first center line, and remove the comment markers from the second center line.

For the remainder of Moom’s AppleScript commands, open Moom’s help, then navigate to the Usage > AppleScript section, via the menu at the top right of the window.

2 Responses to “How to: Use Moom in macOS Shortcuts”

  1. Jim Krenz says:

    Thank you for the example AppleScripts! Moom rocks!

  2. Nathan Bugeja says:

    These example AppleScripts are exactly what I needed. You guys are absolute legends!

Leave a Reply

Your email address will not be published. Required fields are marked *