0

I just want to use AppleScript to open an existing group in Mac Address Book (v7.1).

tell application "Contacts"
    set selected of group "friend" to true
    activate
end tell

above is the sample code for what I want.

1
  • I just updated the code for what I want, it's workable for Mac Address Book (v7.1) now.
    – reallulo
    Aug 24, 2013 at 15:31

2 Answers 2

1

This probably isn't the best Applescript code ever written but it did work for me to list the people in a specific group (on 10.8 mountain lion).

tell application "Contacts"
    activate
    set grp to first group where (name = "friend")
    tell grp
        get people
    end tell
end tell
1
  • tell application "Contacts" set selected of group "Name of Group" to true activate tell application "System Events" to keystroke (key code 99) end tell
    – reallulo
    Aug 24, 2013 at 15:26
0

Above script works only if the group with name 'friend' actually exists. Otherwise the statement 'set grp to first...' fails. Thus it is safer to write

tell application "Contacts"
  activate
  if group "friend" exists then
    set grp to first group where (name = "friend")
    tell grp
      get people
    end tell
  end if
end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .