Hostingheaderbarlogoj
Join InMotion Hosting for $3.49/mo & get a year on Tuts+ FREE (worth $180). Start today.
Advertisement

Save Time by Automating the Mac

by

Most people have the wrong idea about automation. They often think of a futuristic fantasy of robots that automatically do everything for you. That would be the ultimate in automation. More practically, automation is any assistance in performing related actions. Therefore, anytime you can get the computer to help in an activity is automation.

For example, entering in numbers in to a spreadsheet and performing calculations with the numbers is a type of automation. Each time the spell checker corrects a misspelled word in the text, it's automation. Even the notification of an email arriving is a type of automation.

Taking advantage of automation is the mindset of looking for ways to have your computer help your activities. Most people, unfortunately, do not have the mindset to take advantage of automation. You think about how to do an activity and just do it. A mindset for automation has the thought of looking for anything performed more than two times as a candidate for automation.

In order to make use of automation, you have to understand the different types of automation and how they work. With that knowledge, you will start looking for ways to put that knowledge in to action.

Types of Automation

All automation comes in one of three types: process automation, trigger automation, and hybrid automation. Each of these have their own sub-types as well. By understanding these types and the applications used for these types of automation, you better know how to create an automation for your needs.

Process Automation

Process automation is the transforming one or more items in to a different item by a predetermined process. Therefore, taking a picture and transforming it in to a different file type with a set number of bit planes is a process automation. 

The changing of a markdown text file to a HTML file is also a process automation. This would also encompass the moving of files from one place to another. When you perform the process automation repetitively, you have batch automation.

Trigger Automation

Trigger automation happens when running a process upon an event. An event is anything that the computer has no direct control over, but can respond to it. 

In the real world, an alarm clock is the classic example of a trigger automation. All automations that follow a When… then… construction is a trigger automation.

I came up with six trigger automation subtypes: time triggers, state triggers, text triggers, hotkey triggers, keyword triggers, and external triggers. I will describe each trigger subtype with it’s when… then… description.

Time Trigger

A time trigger automation is any activation of a program on a timed interval. It can be as simple as a message about an upcoming meeting or a routine that launches Skype to make the meeting possible. 

Polling a directory for new files and performing an action upon them is a time trigger automation. 

When a certain time interval or date happens, then perform an action.

State Trigger

State trigger automation is the process of over viewing a system and performing an action based on the systems change of state. 

In home automation, a thermostat is a state trigger automation. When the house temperature reaches a certain point, the thermostat triggers the turning off or on of the air conditioner. 

When the computer is in a certain state, then perform an action.

Text Trigger

Text trigger automation is a specialized form of state trigger. A text trigger automation only watches over the keyboard input to determine the sequence of the text typed. When a certain sequence gets detected, an appropriate action and/or text replacement gets performed. 

This is different from keyword triggers in that this type of automation does not make use of a special input area. Any program that receives text can receive text trigger automation. 

When the user types a certain key sequence anywhere, then change the text and/or perform an action.

Hotkey Trigger

Hotkey trigger automation is another specialized form of state trigger. A hotkey trigger automation only watches for a certain combination of keys pressed together. It will perform a special action that gets assigned to that combination. 

All text editors make use of this type of automation. When certain keys get pressed together, then perform a certain action.

Keyword Trigger

A keyword trigger automation is a text trigger automation in a specialized text input area. These can take extra input to perform the automation as well. With this broad of a definition, the terminal is a keyword trigger automation. 

When a certain text gets keyed in to a specialized text input, then perform an action with or without extra input from the user.

External Trigger

An exteral trigger automation is the triggering a process based on a stimulus from outside the program or computer. It is not monitoring, but responding to a stimulus. This is analogous to a clicker on a slide projector. The presenter clicks the clicker to get the projector to change slides. 

The external trigger does not have to be a device, but can be a service. Push notifications is an application of external trigger automation. 

When an event from outside the program or computer happens, then perform a predetermined action.

Hybrid Automation

Hybrid automation is the combination of any of the aforementioned automation types put together. Hybrid automation is generally the most powerful type of automation, but it often is the hardest to put together and maintain. 

The easiest form of hybrid automation is a sequential automation: one automation triggers another automation that is non-related. This differs from batch automation by invoking a different type of automation.

Programs for Automation

Now that I’ve explained the types of automation, I’ll give you some programs to think about each type of automation and how you can put it to work for you. This isn’t an exhaustive list of programs to use for each type of automation, but a short list to get you started.

Process and Batch Automation

Two great program for doing generic process automation are DropZone and Alfred. These two programs allow you to process items and create customizations that fit a particular need. These programs also allow for simple batch processing of actions.

Alfred Workflow for Project Management
Alfred Workflow for Project Management

Alfed Worklfows exist for many task automations. The Packal website lists over 220 workflows. The Project Management workflow automates the creation of new web projects, launching servers, and anything else I add to it. It’s my workhorse of project automation. 

You can see how the base of it created in Alfred Workflows for Advanced Users.

Dropzone Compressing Images
Dropzone Compressing Images

Dropzone comes with several pre-built actions and the ability to add more. In the tutorial Writing Destinations for Dropzone, you see how to create an action to take any image and compress it to a smaller bit plane and to a different type. Once written for doing one image, it is automatically setup to run batch processing as well.

TextSoap Cleaner Construction
TextSoap Cleaner Construction

TextSoap is a process automation for text only. It allows you to change text in many ways: different types of cases, Markdown to HTML or Richtext, and custom text cleaners that’s built with an easy to use flowchart construction method. 

The tutorial How to Effortlessly Create Markdown With TextSoap shows how to create text processing automations.

Time Triggers

To make use of time automation, you have to have programs that know about time and can react to the time. A simple calendar program like Fantastical is great, but it does not automate an action. It gives great reminders, but does not help in the work you need to do.

Clockwise Setting Up Action
Clockwise Setting Up Action

Therefore, programs like Clockwise and Alfred Cron make for true automations. These programs allow you to run a script at a certain time point. 

Clockwise would be the program of choice for programming novices. It has many built-in actions along with user definable scripts. Alfred Cron is for advanced users. 

The tutorial, Use a Mac to Monitor Website Uptime or Other Regular Tasks, shows how to automate actions on time using these applications.

State Triggers

There is only one true State Trigger program for the Mac that I know about: ControlPlane.

ControlPlane works by monitoring many factors in your Mac to determine the current state. Once the state changes, scripts can execute to automate the Mac. The tutorial Take Control With ControlPlane shows how to use this program to automatically turn on and off file sharing based on location.

A limited form of State Triggering happens with programs like LiveReload and Hazel. These programs are known as File State Triggering automations. They watch the state of certain files. When their state changes (ie. changed by a save file action), then they perform a pre-defined action.

LiveReload
LiveReload

LiveReload recompiles web centric resources. Therefore, if you use Compass or SASS, or many other web centric pre-compilers in your project, set live reload to monitor your directories. Anytime you change a file in those directories, it automatically recompiles them and reloads the change in to your browser.

Hazel
Hazel

While LiveReload does a specific type of file processing, Hazel is more generic. It polls predetermines files for a large number of possible changes and performs an action. 

You can configure Hazel to function like LiveReload and more, though Hazel is not as responsive as LiveReload for this type of functionality because of it’s polling nature.

Text Triggers

When I need Text Triggers, I reach to TextExpander to fill that area. Combined with PopClip and the TextExpander Extension, I can create text expanders quickly.

TextExpander Selecting Text
TextExpander: Selecting Text

You can select the text you want to expand and select the TextExpander Extension in PopClip.

TextExpander Assigning Expanding Key
TextExpander: Assigning Expanding Key

Set the key trigger. I use ;q as my default work expander that I do not keep. Now, to repeat that sequence of text, I can type ;q and it expands. When done, delete it or set it to a unique expansion text for future use. 

By using a semi-colon before the letter sequence, you can be sure that it will not get triggered by normal typing. This saves a lot of typing!

Hotkey Triggers

For Hotkey Triggers, Keyboard Maestro is my main application with Alfred doing the rest.

Coupled with ShortCat, a program that allows you to select interface features solely from the keyboard, you can make some interesting automations.

Keyboard Maestro and ShortCat Automating Web Forms
Keyboard Maestro and ShortCat Automating Web Forms

For example, one of my jobs is uploading video courses to Wistia and getting them formatted properly. I use a Keyboard Maestro hotkey action to create a new section in the course. 

In the above Keyboard Maestro dialog, a Cmd-Up Arrow moves to the top of the web page in Chrome. A Shift-Command-Space calls ShortCat to look for a field called Project Action. That opens a menu. 

The script calls ShortCat again to select a menu item in that menu. What normally takes me several mouse moves is a single keyboard shortcut. That is automation at it’s finest!

Keyword Triggers

To create a keyword Trigger, I mostly use Alfred by creating a workflow for the actions needed. In an Alfred workflow, I can use any programing language I want to create the actions. 

The group of tutorials teaching the use of Alfred will help you learn to create keyword triggered actions: Alfred for Beginners, Intermediates, Advanced, and Alfred Debugging.

LaunchBar 5 AppleScript Actions
LaunchBar 5 AppleScript Actions

LaunchBar likewise is useful in creating actions triggered by a keyword. In version 5, they had to be AppleScript scripts. 

Any AppleScript script placed in the ~/Library/Application Support/LaunchBar/Actions/ directory is accessible in LaunchBar as a keyword action.

LaunchBar 6 Packaged Actions
LaunchBar 6 Packaged Actions

The latest version 6 of LaunchBar adds the ability to use any programming language to create scripts and a nice way to package all the needed information together.

External Triggers

Both Keyboard Maestro and Alfred allow for programs other than itself to call their functions with an External Trigger

Keyboard Maestro goes one further and supports an internal Web Server to receive triggers from anywhere on the Internet. You can therefore have a computer somewhere on the Internet send a trigger event to Keyboard Maestro on your computer.

Alfreds External Trigger
Alfred’s External Trigger

Alfred’s External Trigger is limited to a program that can run an AppleScript script to call it. When you define an External Trigger, Alfred gives you the AppleScript code to use to call it.

Hybrid Automation

Since Hybrid Automation is the combining of multiple automation techniques together, there really is not a single application designed for this purpose. 

As you can see from my list of applications, Alfred is in many of the categories. Since it is easy for Alfred to call itself, creating a Hybrid Automation is very doable.

Conclusion

In this tutorial, I have explained computer automation and how to perform it on a Mac. 

It’s up to you to transform your workflow to take advantage of automation. Just keep thinking: I can automate anything done more than twice.

Advertisement