{"id":5662,"date":"2021-12-13T12:49:25","date_gmt":"2021-12-13T20:49:25","guid":{"rendered":"https:\/\/manytricks.com\/blog\/?p=5662"},"modified":"2024-04-29T18:38:39","modified_gmt":"2024-04-30T01:38:39","slug":"how-to-use-moom-in-macos-shortcuts","status":"publish","type":"post","link":"https:\/\/manytricks.com\/blog\/?p=5662","title":{"rendered":"How to: Use Moom in macOS Shortcuts"},"content":{"rendered":"<p>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&#8217;ve heard the requests: We are investigating Shortcuts to see how we can improve support in the next major version of <a href=\"https:\/\/manytricks.com\/moom\">Moom<\/a>. But just because better support may be coming in the future doesn&#8217;t mean you&#8217;re locked out of working with Moom in the Shortcuts app right now.<\/p>\n<p>Moom has long supported a basic AppleScript dictionary, and Shortcuts can (with a simple setting change) execute AppleScripts. Once you&#8217;ve made that change, you can use Shortcuts to interact with some of Moom&#8217;s features. In particular, you can:<\/p>\n<ul>\n<li>Activate a saved window layout snapshot.<\/li>\n<li>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).<\/li>\n<li>Center the frontmost window, either using macOS guideline (which is slightly above screen center), or to the exact screen center.<\/li>\n<li>Generate a list of saved window layout snapshots.<\/li>\n<\/ul>\n<p>Here are a few examples to get you started.<br \/>\n<!--more--><\/p>\n<h3>Enable Shortcuts&#8217; AppleScript support<\/h3>\n<p>The first thing you need to do is allow Shortcuts to execute scripts, including AppleScript. Open Shortcuts&#8217; preferences, select the Advanced tab, and click the first option, Allow Running Scripts:<\/p>\n<p class=\"centercontainer\"><img decoding=\"async\" src=\"\/images\/blogimages\/shortcuts_advanced.png\" class=\"nonzoomingscreenshot\" style=\"width: 432px\"><\/p>\n<p>Once you&#8217;ve done that, you&#8217;re ready to access some of Moom&#8217;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 <em>Run AppleScript<\/em> step to your shortcut:<\/p>\n<p class=\"centercontainer\"><img decoding=\"async\" src=\"\/images\/blogimages\/shortcuts_addscript.png\" class=\"nonzoomingscreenshot\" style=\"width: 350px\"><\/p>\n<p>After that, you just need to replace the boilerplate script\u2014all of it\u2014with the Moom action that you&#8217;d like to perform in your shortcut.<\/p>\n<h3>Restoring a saved window layout snapshot<\/h3>\n<p>Use this script to restore a saved window layout snapshot:<\/p>\n<div class=\"applescript rg_scrollbox\" style=\"height:90px\">\n<span class=\"asbb\">tell<\/span> <span class=\"asibu\">application<\/span> <span class=\"as\">&#8220;Moom&#8221;<\/span><br \/>\n    <span class=\"asbub\">arrange windows according to snapshot named<\/span> <span class=\"as\">&#8220;Snapshot Name&#8221;<\/span><br \/>\n<span class=\"asbb\">end tell<\/span>\n<\/div>\n<p>Replace <tt>Snapshot Name<\/tt> with the name of the saved snapshot.<\/p>\n<h3>Create a new saved window layout snapshot<\/h3>\n<p>Use this script to save a new window layout snapshot:<\/p>\n<div class=\"applescript rg_scrollbox\" style=\"height:90px\">\n<span class=\"asbb\">tell<\/span> <span class=\"asibu\">application<\/span> <span class=\"as\">&#8220;Moom&#8221;<\/span><br \/>\n    <span class=\"asbub\">save window layout and replace snapshot<\/span> <span class=\"as\">&#8220;Snapshot Name&#8221;<\/span><br \/>\n<span class=\"asbb\">end tell<\/span>\n<\/div>\n<p>Replace <tt>Snapshot Name<\/tt> with the name you&#8217;d like to give to the new snapshot\u2014if 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.<\/p>\n<h3>Center the frontmost window<\/h3>\n<p>This very simple script will center the fronmost window:<\/p>\n<div class=\"applescript rg_scrollbox\" style=\"height:110px\">\n<span class=\"asbb\">tell<\/span> <span class=\"asibu\">application<\/span> <span class=\"as\">&#8220;Moom&#8221;<\/span><br \/>\n    <span class=\"asbub\">center frontmost window<\/span><br \/>\n    <span class=\"asgray\">&#8211;center frontmost window geometrically<\/span><br \/>\n<span class=\"asbb\">end tell<\/span>\n<\/div>\n<p>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&#8217;d rather have the window exactly centered, comment out (or delete) the first <tt>center<\/tt> line, and remove the comment markers from the second <tt>center<\/tt> line.<\/p>\n<p>For the remainder of Moom&#8217;s AppleScript commands, open Moom&#8217;s help, then navigate to the Usage > AppleScript section, via the menu at the top right of the window.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[26,28,4],"tags":[],"coauthors":[21],"class_list":["post-5662","post","type-post","status-publish","format-standard","hentry","category-how-to","category-moom","category-products"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5662"}],"version-history":[{"count":36,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5662\/revisions"}],"predecessor-version":[{"id":5993,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5662\/revisions\/5993"}],"wp:attachment":[{"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5662"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcoauthors&post=5662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}