MacOS Keyboard Automation


A coworker asked me to summarize the desktop utilities I use. I didn’t know I had knowledge anyone wanted! Here’s a list of tools I regularly use to bend my environment to my whims. The most important quality in a tool is that it blends into the background and I don’t have to think about it. In order of ease of use:


First thing is to enable keyboard control of GUI elements. This will enable you to press [tab] to switch between buttons in modal dialogs.

System Preferences → Keyboard → Shortcuts → Full Keyboard Access… → All Controls


Ok, so this is easy. It’s like Spotlight. Map it to Cmd+Space. Use it to launch all your applications, lock your computer, search your files, search the internet. Add custom search keywords; I have some set up to search the internal admin dashboard and wiki at work. DevDocs.io is another great custom search to add.

This is the most basic (and free) use. We’ll be back.


Control windows with keyboard shortcuts.

There are others, but those are the ones I primarily use.


Now we’re getting spicy. Map keys to other keys.

Alfred (paid)

Ok, so the paid version of Alfred lets you create elaborate workflows using stuff you type into the launcher as input. Look at what you can build:


In terms of power and ease of use, this is sort of a massive multipurpose chainsaw that you program using Lua. It slightly overlaps with everything else on this list. You can change the way alt-tab works. You can mute iTunes when your laptop connects to wifi at work. You can make your terminal and IDE always open on the same screens in the same positions.

This is a very deep rabbit hole.


You’re gonna start running into this with Alfred workflows or maybe Hammerspoon pretty quick. It lets you automate basically anything you can do with a mouse and keyboard. Pull up Script Editor and poke around. It’s very powerful. It’s also fiddly and fragile. Applications don’t always do what you want them to do instantly, so you end up with lots of code that works like this:

And so on. But it’s so useful you’ll probably end up using it quite a bit for automating GUI apps.

Yes, you can use Alfred to launch a Hammerspoon macro that calls AppleScript.


It’s much easier to automate terminal applications than it is UI stuff. Lots of small commands fit together in satisfying, occasionally productive ways. Learn how to use Bash and write scripts. I don’t know of a good tutorial, but command line knowledge in general is super useful for a developer.

You may also see references to Zsh or Fish. Those are good too!

Vim or Emacs

Learn to edit text using Vim or Emacs. Vim lets you do build tiny macros with text on the fly. Emacs is kind of an application platform that happens to have a text editor in it. If you know the basics of either of these, you’ll start wanting to use them everywhere. MacOS lets you use Emacs editing commands in literally every text box. I use Chrome’s cVim extension to browse the internet using my keyboard.

© 2021 JamesGecko