Advertisement

Adding copy-to-clipboard rollovers in Contacts app via AppleScript

Adding Copy to Clipboard Rollovers in Contacts App via AppleScript

Apple's Contacts app includes a lot of great shortcuts for initiating different forms of communication. Just click an email address, phone number or URL field label to display a list of available options. You can send an email, show a phone number in large type or start a FaceTime call, for example. Curiously, one shortcut that's absent from most of these popups is one for copying the email address, phone number, URL, etc. to the clipboard. Mailing addresses are one exception, as they provide an option to copy a mailing label. But, other fields don't include this option. Sure, you could just select a phone number, email address, URL, etc., and press Command+C to copy it. But, what fun is that? It sure would be nice if there were just more handy copy-to-clipboard shortcuts instead. With the help of AppleScript, you can add your own. Here's how...

Writing the Script

The following steps demonstrate how to add a Copy to Clipboard shortcut to phone number fields in the Contacts app. If you have any trouble following along, you can download the complete script here, along with ones for email address and URL fields too.

1. Launch AppleScript Editor (in /Applications/Utilities)

2. Create a new script document and enter the following code:

Note: If you want to create a version of this script for email address or URL fields, just change the action property handler to return the appropriate field type, i.e.,

on action property
return "email"
end action property

or...

on action property
return "url"
end action property

Installing and Using the Script

In order for the script you created to appear in the Contacts app, it needs to be saved in the proper place.

1. Quit Contacts if it's running.

2. Save the script you created as Contacts > Copy Phone to Clipboard.scpt, in script format, into the ~/Library/Address Book Plug-Ins folder in your Home directory. If this folder doesn't already exist, go ahead and create it.

Adding Copy to Clipboard Rollovers in Contacts App via AppleScript

Now, just relaunch the Contacts app. When you click on a phone number field label, you should see a new option for copying the phone number to the clipboard. Now, repeat the steps above for email addresses and URLs to enhance the Contacts app even further.

Adding Copy to Clipboard Rollovers in Contacts App via AppleScript

This marks my last scheduled post for the TUAW for a bit. Hopefully, you'll see more of me here in the future. In the meantime, feel free to reach out to me on Twitter to say "Hello," ask a scripting question or two, suggest a future topic, etc. Until next time, Happy Scripting!