Re: Scripting Jag's Address Book
Re: Scripting Jag's Address Book
- Subject: Re: Scripting Jag's Address Book
- From: Norman Cohen <email@hidden>
- Date: Sun, 1 Sep 2002 15:08:22 -0600
I diddled up a script that will get the addresses as long as the user
first copies the full name of the address entry to the clipboard. If
there are multiple entries with the same full name, it gets the
addresses from each entry. Here it is:
tell application "Address Book"
activate
set theFullName to ""
set theAddress to ""
set theStreet to ""
set theCity to ""
set theState to ""
set theZip to ""
set theLabel to ""
set theFullName to the clipboard
set theAddress to theFullName & return
set thePeople to every person whose name is equal to theFullName
repeat with thePerson in thePeople
set allAddresses to every address of thePerson
repeat with eachAddress in allAddresses
set theStreet to the street of eachAddress as text
set theCity to the city of eachAddress as text
set theState to the state of eachAddress as text
set theZip to the zip of eachAddress as text
set theLabel to the label of eachAddress as text
if theStreet as string is not equal to "" then
set theAddress to theAddress & return & theLabel & return &
theStreet ,
& return & theCity & ", " & theState & space & theZip & return
end if
end repeat
end repeat
if theAddress is not equal to "" then
display dialog theAddress & "The clipboard contains the address!"
set the clipboard to (theAddress as string)
else
display dialog "The address is empty! Your clipboard is unchanged!"
end if
set the clipboard to (theAddress as string)
end tell
On Sunday, September 1, 2002, at 01:54 PM, Paul Berkowitz wrote:
On 9/1/02 11:32 AM, "Norman Cohen" <email@hidden> wrote:
New to this list but have been doing some limited AppleScripting for
years. Is there a way to use AppleScript to get the person entry data
for the record showing in Jag's new Address Book application? Looking
through the dictionary, I didn't see any reference within the
application, document or window class for the currently showing
record.
There doesn't appear to be anyway to do this. There is nothing
corresponding
to 'selection'. The dictionary does have a 'document' class which is
currently totally unused, so maybe one day you'll be able to refer to
'document 1' to mean 'currently displayed card' [hint to Apple]. For
now,
the only thing UI can think of is a _very_ clunky workaround: tell the
user
to drag the current card to the desktop and select it, then tell the
Finder
to get the name of 'item 1 of (get selection)' and - if it corresponds
to an
AB person- go ahead.
tell application "Finder"
try
set theThing to item 1 of (get selection)
set theName to name of theThing
set theExtension to name extension of theThing
if theExtension /= "vcf" then error number -128
on error
display dialog "You forgot to select the vCard."
return
end try
set dName to displayed name of theThing
end tell
tell application "Address Book"
try
set thePerson to person dName
on error -- some other vCard not yet imported!
display dialog "You forgot to make a vCard on your desktop and
select it."
return
end try
-- your other stuff
end tell
--When all's said and done, although Address Book is quite
serviceable, it's
not got 1/50th of the features or scriptability of an app like
Entourage
although I do really like the 'label' property, especially for phones.
--
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.
Norman Cohen
email@hidden
_______________________________________________
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.