Automate your Mac

Automate your Mac: 10 ways to speed up iTunes, Safari, and more

keyboard maestro gallery

Today's Best Tech Deals

Picked by Macworld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

Insert passwords

Tool: Keyboard Maestro
Apple has (wisely) made it impossible to auto-expand text in certain secure fields—password fields, for example. That makes it hard to use standard keyboard expansion utilities (including Apple’s own) to fill in password fields. However, Keyboard Maestro is happy to paste templated text into such fields with the press of a keyboard shortcut. So that’s the tool I use when working with convoluted passwords and inflexible fields. I would definitely not implement this on a shared Mac where I wanted to keep my passwords private, however.—Christopher Breen

Lock your Mac when you leave

Tools: AppleScript, Dropbox, Hazel, IFTTT
I have a job that’s somewhat security-sensitive, so I make a point to lock my Mac’s screen whenever I step away. As a backup, I have a screensaver set to activate after 10 minutes which requires a password to deactivate. Occasionally I forget to lock my Mac before I leave the office. But using my iPhone in concert with IFTTT, Hazel and Dropbox, I can automatically trigger the screensaver to activate and lock the screen whenever I leave the immediate area, even before that 10 minutes is up.

31.11 automate floyd lock mac hazel

To start, you’ll need an IFTTT account ( and the accompanying iPhone app. You use the latter to set up a location-based trigger for whenever you exit an area. For the consequence of that trigger, tell the service to create a text file in your Dropbox account. After you initially create the recipe, select it in your list of recipes and click the Edit button. In the File Name box, name it as you wish; I choose lock_computer followed by the default {{OccurredAt}} token, which will add the date and time to the file’s name.

That done, I created a Hazel rule to watch the Dropbox folder where IFTTT will be depositing these text files (by default, it’s /Dropbox/ifttt/ios location) for files matching two criteria: Name Contains “lock_computer” and Date Created Is In The Last 1 Hour. (The latter prevents accidental triggers when your computer wakes up from sleep.) When Hazel finds such files, the rule moves the found file to the Trash and runs an AppleScript:

tell application "ScreenSaverEngine"
end tell

With all that set up, whenever Hazel sees the text file created by IFTTT, it will automatically kick off the script and activate the screensaver.—Katie Floyd

Move windows back to default positions, sizes

moom window shortcuts

Tool: Moom
There are a few apps that are always running on my Mac, and I almost always want their windows to be in particular locations with particular sizes. But sometimes I move or resize such windows temporarily, or the app or OS X itself does so without my asking. Rather than manually restoring these windows to their preferred configurations, I use Many Tricks’ Moom to set up keyboard shortcuts for my favorite window sizes and positions.

To do so, you open Moom’s preferences window and switch to the Custom screen. Create a new custom item by pressing the Add (+) button, choose Move & Zoom as the item type, and then “draw” the desired window size and placement on Moom’s representation of your screen. Next, click in the keyboard-shortcut field and press your desired single-key shortcut. Now, whenever you want to restore, say, your Safari window to its preferred configuration, you just bring up Moom’s keyboard-control bezel (which, of course, you can do with a keyboard shortcut), and then press the key for Safari (in my case, S). Moom even lets you configure, and easily switch between, sets of window configurations.—Dan Frakes

Take, rename screenshot of frontmost window

Tool: Keyboard Maestro
I often take screenshots of windows on my Mac and then either email them, send them via iMessage, or upload them somewhere to share with others. OS X lets you natively take window-specific screenshots by pressing Command-Shift-4 and then the Space key, but the resulting screenshot files have awkward file names like Screen Shot 2014-08-04 at 17.51.22.png. So I use Keyboard Maestro instead to capture the frontmost window and then write the image to a file on my Desktop, using a name derived from the window’s title (which I can override if I want to).

The first action in the Keyboard Maestro macro is Screen Capture, specifying Capture the Front Window and to Default Clipboard from the drop-downs. The next three steps assign the name of the frontmost window (%WindowName%1%) to a text variable (window_name, filters that variable to lowercase, and replaces all the spaces in that variable with dashes. The macro then prompts for user input, suggesting the suitably-formatted window title the preceding steps created but allowing me to add on to it as I wish. The last step writes the contents of the default clipboard to file with the specified name to my desktop.—Matt Gemmell

Print any selected text

Tool: Automator
One feature that Windows users enjoy (and some Mac users envy) is the ability to print any selection of text, be it on a webpage or in a word processing document. However, you can replicate this service in OS X with Automator.

To start, create a new Service workflow in Automator. Set Service Receives Selected to Text and In to Any Application. Drag the New Text File action over to your workflow. Select Same As Input Text from the File Format drop-down, then specify a filename such as tempFile.txt in the Save As box. Choose a location for the document (such as your Downloads folder) and check the option to Replace Existing Files.

Next, drag the Print Finder Items action to the workflow, and choose Default Printer as the device to use. Finally, save the workflow with a name like Print Selected Text.

All this done, you can select some text in almost any application, then right-click it and choose the Print Selected Text service from the contextual menu. You can also assign the workflow a keyboard shortcut in the Keyboard pane of System Preference: Select the Shortcuts tab, choose the Services section on the left, scroll down to the bottom of the services list, find your new service listed, then add your custom hotkey.—Topher Kessler

print selected text

Import music from Dropbox to iTunes

Tools: Dropbox, Hazel
A couple of bands I like have run Kickstarter projects to fund their albums, after which songs were made available to backers via Dropbox. After following the download URL, I’d click Save to My Dropbox, which resulted in a bunch of MP3 files sitting at the top level of my Dropbox folder. I use Hazel to look for such files and, when found, import them into iTunes—and then delete the originals from my Dropbox. (This technique can be adapted for importing photos into iPhoto and processing other media types.)

In the Hazel pane of System Preferences, click the Add (+) button under Folders, navigate to your Dropbox folder, and click Open. Then, with Dropbox selected on the left, click the Add (+) button under Rules. Give your rule a name (such as Add Music to iTunes). Set a single condition: Kind is Music. Then add two actions: Import into iTunes (choosing whichever playlist you like) and Move to Folder Trash. Click OK. From now on, shortly after new music files appear in the top level of your Dropbox folder, they’ll be added to iTunes and then the originals will be deleted.—Joe Kissell

hazel Dropbox music

Quickly access Login Items list

Tool: Keyboard Maestro
If I want to edit my Login Items list, I can always open the System Preferences app, click Users & Groups, and click the Login Items tab. But because I edit this list frequently, I like having a shortcut that takes me directly there.

In Keyboard Maestro, choose File > New Macro and enter a name (such as Open Login Items). Choose Hot Key Trigger from the New Trigger pop-up menu. Press a key combination (I use Command-Control-L). Click New Action, and then find and double-click Open a System Preference Pane (found in the Open category). Choose Users & Groups from the Open Preference Pane pop-up menu (if it isn’t already shown there).

Next, double-click the Pause Until action (in the Control Flow category). Choose Front Window Condition from the New Condition pop-up menu. Then choose System Preferences from the Front Application pop-up menu; if you don’t see it, look under Recent. (Leave everything else set as is.) Double-click Press a Button (in the Interface Control category) and replace the text OK with Login Items.

That’s it. Now, when you press your designated keyboard shortcut, the Login Items tab will open.—Joe Kissell

open login items

Paste previous clipboard

Tool: Keyboard Maestro
I often paste something and then immediately realize I wanted the previous contents of my Clipboard. Several Mac utilities keep clipboard histories so that you can review and paste earlier Clipboard contents. But I like to have a quick keyboard shortcut that will paste whatever was in there just before the current thing.

In Keyboard Maestro, choose File > New Macro and enter a name (such as Paste Previous). Choose Hot Key Trigger from the New Trigger pop-up menu. Press a key combination (I use Command-Control-V). Click New Action, and then double-click Set Clipboard to Past Clipboard (found in the Clipboard category). Leave the past clipboard number set to 1. Next, double-click Type a Keystroke (found in the Text category), click in the Simulate Keystroke field, and press Command-V.

To use the macro, copy something to your Clipboard normally (for instance, with Command-C) and then copy something else. Press Command-Control-V (or your chosen shortcut) to paste the previous item. As a bonus side-effect of the way Keyboard Maestro handles the Clipboard, you can use this keyboard shortcut repeatedly to alternate between the last two items on the Clipboard.—Joe Kissell

kissell paste previous clipboard

Create Amazon links

Tool: TextExpander
I review books, CDs and DVDs on my website and make a few bucks from resulting Amazon affiliate links. Rather than grabbing those links from Amazon’s affiliate dashboard, I created some simple ones using the ASIN or ISBN of a product. And I use a TextExpander snippet that creates clickable links for me that I can add to my blog posts. Since I link to two different Amazon stores— and Amazon UK—the snippet creates links to both.

To start, I create a new snippet in TextExpander. For the Content of the snippet, I enter the following code:

(<a href=""></a>, <a href="">Amazon UK</a>)

(You’ll want to substitute your actual affiliate ID for that AFFILIATEID placeholder.) I then assign the snippet an abbreviation (bz, in this case) and save it.

To use this snippet, I copy the ASIN or ISBN of the item I want to link to, then type bz. In return, TextExpander pastes in the correct links.—Kirk McElhearn

Quickly copy-paste URLs

Tool: TextExpander
When I’m writing a blog post or an email, I frequently want to refer to a URL that I just found in Chrome. I could switch back to the browser, select the URL and copy it, then switch back to whatever application I was writing in and paste it. Or I could just type ,,curl in my document, which is my abbreviation for a TextExpander snippet that runs a simple AppleScript:

tell application "Google Chrome" to return URL of active tab of window 1

When triggered, the script grabs the URL for the active tab in Chrome and inserts it into whatever I’m writing. You can modify the script to work with Safari by changing it to:

tell application "Safari" to return URL of current tab of window 1

In either case, when you’re setting that up, select AppleScript from the Content drop-down at the top of the TextExpander window.—Brett Terpstra

Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read our affiliate link policy for more details.
Shop Tech Products at Amazon