Re: Scripting Jag's Address Book
Re: Scripting Jag's Address Book
- Subject: Re: Scripting Jag's Address Book
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 01 Sep 2002 14:27:10 -0700
Ah yes, the clipboard. Good idea.
Why all the 'as text' and 'as string' stuff? (I haven't tried it yet - does
Unicode not coerce automatically to the styled text that the clipboard uses?
I would have thought it did...) And why not paste what's in the clipboard to
wherever you want it? Maybe instead of putting a carriage return between
each label and its value, you might want just ": " ?
I think you also have each address wiping out the previous one (not to
mention each duplicated person wiping out its duplicate). Is that really
what you want to happen if there's both a home and a work address?
--
Paul Berkowitz
>
From: Norman Cohen <email@hidden>
>
Date: Sun, 1 Sep 2002 15:08:22 -0600
>
Cc: Applescript-Users <email@hidden>
>
Subject: Re: Scripting Jag's Address Book
>
>
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.
_______________________________________________
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.