November 20, 2016 at 9:14 PM by Dr. Drang
Here’s a bit of automation I’m not particularly proud of, but it got the job done and saved me a lot of time in two ways. It’s the clearest evidence I can muster that you don’t have to be a good—or even halfway decent—programmer to take advantage of automation.
A couple of weeks ago, I needed to drive around an unfamiliar area to do a brief overview of a couple of dozen buildings that I was going to be inspecting in detail the following week. Because this pre-inspection was going to be done on a Sunday, I wanted it go as quickly as possible. I had the addresses of all the buildings, and I knew they were all in an area that covered only a few square miles, but because I didn’t know the area well, I couldn’t figure out the most efficient way to visit all the properties just by looking at the addresses.
The best way to plan my tour would be to have them all laid out on a map. Both Apple Maps and Google Maps make it easy to plot a single address, but they don’t make it easy to several addresses at once. In the past, I’d been able to do that through the Google Maps API, but that was many years ago, and I didn’t feel confident that what I knew back then would still work today.
Both Apple and Google Maps let you save locations, but it’s a manual process that requires several steps for each address. I decided to automate that process with a Keyboard Maestro macro that mimicked the steps I would take doing the job manually. I chose to use Apple Maps, because I prefer its user interface and because I was certain that addresses saved in Maps on my Mac would be available in Maps on my iPhone.
The way to get several addresses saved in Apple Maps is to add them to your Favorites list. Once they’re in your Favorites, they’ll appear automatically in any view on your iPhone that includes their location.
(These are not the addresses I was going to inspect. I just chose a bunch of spots in Berwyn for the purposes of this illustration. Why Berwyn? To amuse any fans of Svengoolie in my readership.)
I started with a list of addresses in BBEdit, one per line. To add an address to Favorites, the macro performs the following steps, just like I would do:
- Select the next line in BBEdit.
- Copy it.
- Switch to Maps.
- Paste the address into Maps’s Find field and do the find.
Click the information button in the flag that appears next to the pin.
Click the share button and choose Add to Favorites from the menu.
Although I can write it as six steps, it works out to many more steps in Keyboard Maestro, partly because things like “Select the next line in BBEdit” involve a few keystrokes, and partly because pauses are necessary at a few spots to allow interface elements to appear. As usual, it took a couple of trial runs to get the pauses right.
If you think you might use this macro, you can download it.
Once I had the macro working, it was a simple matter to just keep hitting ⌃⌥⌘F again and again until I’d worked my way through the list of addresses and had Favorites fully populated. I then opened Maps on my phone and there they were.
I said at the beginning that this macro saved my time in two ways. First, of course, it saved me time in adding all the addresses to my Favorites list. More important, though, is the time it saved me in routing myself efficiently to all the buildings. That was worth at least two hours of my Sunday.
And as you can see, there’s nothing clever about this macro. It doesn’t involve loops, decisions, functions, or any other computer sciencey stuff. It’s just a straight translation of the manual steps into Keyboard Maestro actions. Anyone can do automation like this, and the Mac would be poorer if this ability disappeared.