Re: Scripting Address Book
Re: Scripting Address Book
- Subject: Re: Scripting Address Book
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 10 Sep 2002 23:39:53 -0700
On 9/10/02 2:41 PM, "Gibbons Burke" <email@hidden>
wrote:
>
I'm trying to write a script that takes the currently displayed address card
>
in the Address Book application and does something with it, like, say, copying
>
the name, company and address to the clipboard so that it can be printed on an
>
envelope, or inserted into a letter in Word, or TextEdit.
>
>
Problem: I can't figure out, from the Dictionary, how to get that information.
>
I would guess that it would work similarly to iTunes, where you can get the
>
name of the currently playing tune ("the name of the current track"), or the
>
name of the current playlist. But I can't find anything in Address Book that
>
corresponds to this sort of thing, and nothing I've tried seems to work.
>
>
I'm a relatively new user of AppleScript, so I don't know if there's something
>
obvious I'm overlooking or if this ability just doesn't yet exist in the
>
applescript api of the Address Book.
There's nothing that corresponds to 'selection' or 'current person' or
people in Address Book scripting. It was simply omitted. (Makes you wonder
)
It has excellent support for 'whose' clauses if you can think of another way
of getting old of it.
However, I've discovered something that might help. If you tell the user to
to select "Copy" or press command-C after selecting a contact name, then
set theSelection to the clipboard
gives you the name of the contact plus a carriage return (well, what did you
expect from this app?)
so you can then
set theName to text 1 thru -2 of theSelection
Then
tell application "Address Book"
set thePerson to person theName
--etc
end tell
If you expect to find contacts with non-MacRoman names you might need a try
block in case their Unicode name in AB does not correspond to whatever the
clipboard picked up.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.