A Better Way to Copy Two-Factor Codes on macOS

Back in June, I posted a completely un-serious post that described a ridiculous Rube Goldberg approach to grabbing two-factor authentication codes from your text messages on macOS using Keyboard Maestro (for those of us who don’t use Safari).

How dumb was it? Let’s just say that it relied on taking a screenshot of Notifcation Center and parsing the code out of the image.

A joke, yes, but also a fun distraction one evening.

To my surprise, very nice reader @ajorpheus provided a real solution in the comment section earlier today.

Their solution is to grab the most recent text from Messsages.app’s actual SQLite database and parse the token from that. Not only is this way, way faster – it’s much more error-proof as well.

Here’s the shell script they provided:

sqlite3 "$HOME/Library/Messages/chat.db"   "select text from message order by date desc limit 1" | perl -lpe "s/.* (\d+) .*/\1/g"

With that, it’s just a matter of dropping the script into a Keyboard Maestro macro like this:

Two-factor auth token Keyboard Maestro macro screenshot

Besides the script itself, all I added was a step to copy the extracted 2FA token to the system clipboard and another to display the token in a system notification so you can confirm the macro ran (and worked?) before pasting.

You can download the macro here.

Please note: The Messages.app database is a protected file on your system. For Keyboard Maestro to access it, you’ll need to grant the app Full Disk Access in System Preferences → Security & Privacy → Privacy.

(Remember to scroll slowly through that list when looking for Keyboard Maestro. It’s been how many years and still none of the Privacy sections sort their lists alphabetically?)

And big thanks to @ajorpheus for coming up with a better way to turn a dumb idea into something useful and reliable.

Retina Studio

Here’s the thing.

When I tell people, “I started my app business in 2007”, that’s not true. I never meant to start a business – it just happened. Because if I had sat down one afternoon and thought, “I’m going to begin selling software online today,” I sure as hell wouldn’t have intentionally named my company Click On Tyler.

For fourteen years, I’ve hated that name.

I began learning Objective-C and Cocoa in 2003. I tinkered around with tiny little projects for a few years. And then, in early 2007, I had the idea for VirtualHostX because I needed it for my day job as a web developer. When I finished the app in August, I had to put it up for sale somewhere.

Back up.

Two years before that, I was on my lunch break browsing recently expired domain names (I’m a nerd) and saw clickontyler.com was available. There weren’t touch screens back then – everything you did with a computer involved clicking. (That’s not true, but you know what I mean.) The domain name sounded fun, so I bought it. Nothing ever came of the website other than an awful About Me-style page.

So when I needed a place to sell VirtualHostX, clickontyler.com was the only website I had up and running. I put the app on the front page next to a PayPal button.

That was it. The name stuck. 50,000 customers. For a few years, my full-time job. And I’ve secretly despised it every day.

In fourteen years, I never even decided if the “On” in Click On Tyler should use capital or lowercase oh. And putting my first name into a company name (unintentionally or not) has always made me feel like my branding is one-step-removed from a solo divorce attorney calling themselves the First Name Group, PLLC. Every time I spoke “click on tyler” out loud to someone, I’d cringe a little bit.

Honestly, Apple ditching Intel CPUs and transitioning to their own chips is the best thing that could have happened to me.

What I mean is, the migration to Apple Silicon killed off VirtualHostX because of its dependency on VirtualBox (made by Oracle). I looked into every technical avenue I could think of to keep the app alive, but there’s no path forward that makes business sense for me.

I spent much of 2021 thinking about what I do now that VirtualHostX has reached its end of life. And I realized, holy crap, despite VHX being what I thought of as my flagship product, I have six other Mac apps that fall outside my original niche of web developer-focused software.

It was my wife who finally said, “Sunset VHX and focus on the rest. Start over.”

As usual, she was right.

And that’s what I did this Summer. I paused and took time to start over with a company name I actually like and that I hope carries me forward another fourteen years or longer.

Retina Studio

Hello.