how to select ALL Address Book entries?

Hi there,

I would like to select ALL my contacts in Address Book. The problem is this:

If Address Book had a specific group selected only the contacts from that group is returned. How can I force Address Book to select “Group ALL”

Here’s the simplified script

tell application "Address Book"
	set AllContacts to people
end tell

This works perfectly if I manually select Group “All”. Is there a way to force the ALL (Master Library) in applescript?

Thanks !

Hi,

the element people of application contains always all contacts regardless of which group is selected.
There is also an element people in each group which contains all contacts of the appropriate group

Hi Stefan,

Indeed you are right. :wink: My problem starts when I use this:

tell application “Address Book”
activate
set selection to people whose name contains theSearchstring
set sel to selection
end tell

To do some filtering, I tried the script above because I wanted “Address Book” to do the searching. I think applescript might be too slow if I have to loop through 3000 contacts.

Any suggestions?

Thanks

This should do it


activate application "Address Book"
tell application "System Events"
	tell process "Address Book"
		set value of attribute "AXSelected" of row 1 of outline 1 of scroll area 1 of splitter group 1 of window "Address Book" to true
	end tell
end tell
tell application "Address Book"
	set selection to people whose name contains theSearchstring
	set sel to selection
end tell


Fantastic !!! :lol: Nice one ! I never thought of interface scripting. You rock !!!

Thanks a lot !

I know this topic is way old but here’s an update to this for later OS X versions:

tell application "System Events"
		tell process "Contacts"
			set value of attribute "AXSelected" of row 2 of outline 1 of scroll area 1 of splitter group 1 of window "Contacts" to true
		end tell
	end tell