10.3: Schedule calls in iCal from Address Book

Feb 04, '04 10:46:00AM

Contributed by: BlackPenguin

I've come to love the ability to add plug-ins to AddressBook. It gives the program a lot of power and makes it easy to add new functionality in an elegant manner. The following script will place a to-do to call a person directly into your iCal calendar.

[robg update: I failed to mark this hint as 10.3 only when I posted it; apologies to those running 10.2.x who tried to get it working.]

Save the script below as a Script file in ~/Library/Address Book Plug-Ins/. Relaunch Address Book and click on the label next to a phone number. Amazing!


using terms from application "Address Book"
  on action property
    return "phone"
  end action property
   
  on action title for p with e
    set theName to (first name of p) & " " & (last name of p)
    return "Schedule call to " & theName
  end action title
      
  on should enable action for p with e
    return true
  end should enable action
      
  on perform action for p with e
    set theName to (first name of p) & " " & (last name of p)
    scheduleCall((id of p), theName)
  end perform action
    
end using terms from

on scheduleCall(id, name)
  tell application "iCal"
    set theItem to (make new todo at end of todo of calendar 1)
    set summary of theItem to "Call " & name
    set url of theItem to "addressbook://" & id
    activate
    show theItem
  end tell
end scheduleCall
The script will open iCal and add a new todo to the first calendar it finds. The todo will read "Call So-and-So", and the URL for the todo will link back to the address book card for that person.

Comments (28)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040128173706350