On Tue, Apr 20, 2004 at 10:50:01PM -0500, Ken Williams wrote:
> Say, I built the Address_Book glue and looked through its docs, but I
> don't see methods to search the database for entries that have certain
> properties. Do you know of any way to use the "Find" functionality, or
> specify required properties, using the applescript/glue interface?
Here's the script I use for querying my addressbook from mutt.
The output format is specific to the mutt interface,
but the commented out section shows how to get the address info.
rick
---- cut here ---
#!/usr/local/bin/perl
use Mac::Glue qw(:glue);
use Mac::Apps::Launch;
my $glue=Mac::Glue->new('Address Book',bundle=>'com.apple.AddressBook');
my $id=$glue->{ID};
if(!IsRunning($id)) {
LaunchApps($glue->{ID}) or die $^E;
$glue->close($glue->prop('window')) or warn $^E;
}
my $q=shift;
print "Querying AddressBook...\n";
my @people=$glue->obj('people')->get;
foreach my $entry (@people) {
my @emails=$entry->prop('email')->get;
next unless @emails;
foreach my $email (@emails) {
my $addr=$email->prop('value')->get;
my $name=$entry->prop('name')->get;
print "$addr\t$name\t",$email->prop('label')->get,"\n"
if $name =~ /$q/ || $addr =~ /$q/;
}
# my($addr)=$entry->prop('address')->get;
# next unless $addr;
# print $addr->prop('street')->get,"\n";
# print $addr->prop('city')->get," ";
# print $addr->prop('state')->get," ";
# print $addr->prop('zip')->get,"\n";
}
exit 0;