Mac Automation

Mac AutomationMac Automation

Since the beginning of this year, everyone has been talking about Artificial Intelligence tools like ChatGPT. While this technology is still in it’s early stages, a lot of people are seeing the potential of what it can do:

  • Write or summarize emails and other documents
  • Prepare reports and copy
  • Create graphics and images

And the list goes on. While this technology is one part of automating our work, there are things it can’t do that other forms of automation can, like:

  • Open up and arrange the apps you need to start your work day
  • Automatically type out a standard email you send all the time based on a couple of keystrokes
  • Automatically tag, rename, or move files based on parameters you set
  • Switch your audio device inputs and outputs based on the work you are doing

These are just some of the things I use computer automation for on my Mac. In this article I’m going to breakdown how you can automate your everyday tasks and give an overview of some of the systems I use to get this work done.

Just to be clear: everything I am going to be discussing is available on the Mac platform. If you use Windows most of the apps are not available. Windows is a great system, but not so much for automation.

Mac Automation - What is it?

If you have used a computer for more than a week, I am willing to bet you have come across some forms of automation, such as keyboard shortcuts. Highlight some text and press Command+C’ and it will copy the text to your clipboard. Place the cursor someplace else and press Command+V’ and it will paste that text in the new location. It saves you the trouble of moving the mouse cursor up to the Edit menu, moving down to the Copy item, and clicking it. Congratulations, you just saved 5 seconds!

This is about as simple as automation gets. But what if I told you there were other ways you could save hours rather than seconds automating your work? You can, with a few other tools and taking the time to learn them.

I define automation as anything you can do to keep work moving by telling your Mac to complete tasks for you, with as little input from you as possible. This can be done in the form of keyboard shortcuts, telling an app to watch a folder and do something if it finds a file that meets certain parameters, or buttons on a Stream Deck.

We have entered a Golden Age of automation, where multiple systems can be combined to produce automations that do a lot more for you. When I start my day, I push one button on my Stream Deck that starts a Keyboard Maestro macro that opens apps for me, but it also runs a couple of different Apple Shortcuts along with some Apple Script to get everything set up exactly the way I want it. This would not be possible without different systems talking to one another.

Systems/Applications

Now that I hopefully have piqued your interest, let’s go over some of the tools that should be in the Automation Sorcerer’s Bag of Holding.

Text Expander

This is a great place to start because it’s pretty simple, very powerful, and if you type you can get something out of it. Text Expander (TE) sits in the background and watches for you to type certain snippets of text and when it sees them, it takes action by either expanding your snippet into a larger text or opening a form for you to fill out before pasting the info into where you are typing. So if you work for the Acme Moving Company” and you type the company name a lot, you could create a snippet of amc.” Whenever you type that, TE is going to change it into Acme Moving Company.”

Acme Moving CompanyAcme Moving Company

You can create a text expansion with as little or as much text as you want. You can also add formatting and placeholder text. It’s a great way to save time by automating things you type on a regular basis.

Hazel

Hazel is an app that watches folders for you, and takes action on files in the folders based on rules you have set up. I take a lot of screenshots, but I usually only need them for about 5 minutes. Rather than go through the process of deleting them or letting them fill up my desktop, I created a Hazel rule. When a file with screen shot” in its name has been sitting on my desktop for 3 days, Hazel moves it to the trash. She also deletes files that have been in the trash longer than 10 days. This eliminates my having to do the maintenance work of cleaning up my screenshots and deleting the trash.

I also have a task every two weeks of downloading a PDF file from a site, then emailing it to my boss. I set up a Hazel rule so that when the file is downloaded, Hazel creates an email addressed to my boss, and attaches the file. She then tags and moves the file to a storage location.

Moom

Now we are going to get into some of the apps that connect well together. Moom is an app for managing your app windows, and can be used two ways. The first is through keyboard shortcuts. Activating a shortcut can move the window to half the screen (vertical or horizontal), center of the screen, nearly full screen, or to a different screen entirely, among others.

MoomMoom

The other way to use Moom is with its savable snapshots. Open all the apps you use for a particular task, place them where you want, and then bring up the Moom Snapshot preferences. Give the snapshot a name and an optional keyboard shortcut. You can then activate the snapshot anytime by either clicking the keyboard shortcut or clicking on Moom in the menu bar and selecting the snapshot. You can also use Moom with Apple Script, but we’ll get to that later.

Apple Shortcuts

If you have an iPhone, you have probably heard of or seen Shortcuts on there. Shortcuts is a jack-of-all-trades type app. It’s a bit hard to explain because there are so many different things you can do with Shortcuts, but I’m going to try.

Shortcuts can be as simple as having only one action, like creating a button to switch focus modes, or to toggle dark mode on or off. Or they can have many actions, like when you toggle dark mode on, it then activates a focus, opens an app, and starts a certain playlist in Music. A great way to use Shortcuts is to go through your day trying to be mindful of the things you are doing, and identifying things you tend to do at the same time. I created a Shortcut for my phone that turns on my AppleTV, then makes sure the AppleTV is switched to my profile, then opens the TV app. If you have Home Kit connected devices you could also set the Shortcut to dim the lights or set a scene.

Gaming Sound OnGaming Sound On

In addition to being able to run actions on your Mac or iPhone on its own, one of Shortcuts super powers is being able to work with other systems. You can create a Shortcut, and then add it to a Keyboard Maestro macro or Hazel action. This lets you extend your automations to do lots of things at once by using different systems together to do what they are best at.

Keyboard Maestro

Keyboard Maestro (KM) is one of my all time favorites. It is the multi-tool of Mac automation apps. It’s another app that is a bit challenging to explain because it can do so much, and your imagination really helps here.

The basic idea of KM is that you create a macro that does one or more tasks based upon a trigger. If you have played around with If This Than That then you have some idea of what I am talking about.

The simplest type of trigger in KM is a keyboard shortcut, like pressing Command+C to copy, except that you can create any shortcut that isn’t already being used by your Mac. You can also create Command Palettes, which is a popover menu that displays when you click a keyboard shortcut. This allows you to assign the same shortcut to multiple macros and then pick from the list either with your mouse or by pressing the a letters in the name of the macro. Further, you can set a macro to fire when something happens on your mac, like running a macro when a certain app opens (I love this one).

Once you name a macro and set a trigger, KM has a list of a gazillion actions that a macro can perform, including running actions from other systems like Apple Shortcuts.

One of my favorite things to do with KM is what David Sparks calls set ups.” This is when you set up your Mac to do a specific type of work like setting up for your work day, or to write, or edit audio or video. In cases like these there are certain apps you want open, in particular places on your screen or screens. You may also want to set a focus or toggle dark mode. KM can do all of that, with the push of one button.

Side note: I tried to take a scrolling screenshot of my work set up, but it was too long. Same with my D&D one.

So, remember how I said some automation systems can work together? If you have been reading all of this to get to that info, get ready to be happy.

KM has actions for running Apple Shortcuts and Apple Script, which is a fairly simple scripting language that has been around almost as long as the Mac. These actions allow you to do things with KM that it otherwise is not set up to do. Here’s a couple of examples:

KM does not have a way to change system preferences. It can open them, but not change them. So when I want to switch my audio input/output from my speakers and microphone to my gaming headset, you would think I was out of luck. However, I use an audio control app called Sound Source, which allows you to make these changes from the menu bar. Since Sound Source has enabled Apple Shortcut actions, I created 2 Shortcuts one to switch my input and output to the headset, and one to switch back. I added this Shortcut to my KM D&D set up macro, and it switches the input and output while the macro is running. I then created a macro for the end of the session, which runs the Shortcut to switch them back.

Another great example is with Moom. KM does not have a way to directly interact with Moom, but it does allow you to use Apple Script. So with a little internet searching, I found the script for activating a Moom snapshot, and added it to my set ups. Voila. Now my windows move to the right places once the apps are opened.

Investing in Your Education

Finally, if you are still reading all of this and thinking Well that’s great, but I’ve never used apps like this” I have one more resource for you. Earlier I mentioned my friend David Sparks, known online as MacSparky. David has created Field Guides for KM, Apple Shortcuts, and Hazel, which are great resources for learning these applications. You can stream or download the videos, and he provides example macros you can download to help you learn. I highly recommend his guides for learning any subject he teaches on.

Do you have any Mac automation tips or tricks? Leave them down in the comments.

automator mac os x leopard by Shht! is licensed under CC BY 2.0.



Date
April 26, 2023