Apple, Pragmatism, Software
Solution of least resistance
At work, I’m in the middle of entering hundreds of addresses into Address Book. I’m happy with my custom template, and there isn’t mechanism for multiple templates, so initially I resigned myself to Shift-Tabbing 7 times to navigate from the Last Name field to the Address field. However, after doing this for the first few entries, my fingers knew there had to be (and wanted) a more efficient way. I turned to AppleScript and Quicksilver.
I’m not an ace AppleScripter. I have some coding experience in a variety of languages, but I’m not familiar enough with AppleScript to have gotten over the fact the “real-language” syntax is counterintuitive to those with prior programming experience.
My first instinct was to check the Address Book AppleScript Dictionary to see if there was a trivial way to select the Address field with GUI Scripting.
A brief search told me there wasn’t, at least not one that I could understsand and code in 5 minutes (or 5 lines). But why go to all this complexity? The number of tabs I’ll need is constant; the template isn’t changing.
tell application "System Events"
repeat 9 times
keystroke tab
end repeat
end tell
It’s that simple. I could assign a trigger, but it’s lower overhead for this one-off to be activated with Control-Space followed by Return (Quicksilver remembers the last Object-Action pair by default, so I only need to search for it once). This script cuts navigation keystrokes from 7 to 2, as well as the mental overhead of counting out all seven Shift-Tabs. Much better.
Is this code snippet novel or revolutionary? Of course not. Neither is the Moral of this story, but it does merit frequent repetition: don’t overthink problems. I could have spent a lot more time researching fiddling with and perfecting a GUI-scripted script, more time than I would have saved once that script was written. I wanted to, but I exercised restraint. Instead, I did what I knew how to do and knew would work, and got on with the real task.





