-2

I want to add CardDav account in Contacts (AddressBook) using AppleScript. Also couldn't write script which can open "Contacts preferences".

Any suggestions?

Mariam
  • 103
  • 2
  • 10

1 Answers1

0

AppleScript GUI Scripting can open Contacts' preferences:

tell application "System Events" to perform action "AXPress" of process "Contacts"'s menu bar 1's menu bar item "Contacts"'s menu 1's menu item "Preferences…"

I don't know about programmatically adding a CardDAV account, though. I don't see commands in Contacts' "dictionary" for adding one, and I have no idea what files & plists would need to be created to add a CardDAV account behind the scenes.

To get an idea, I created a test CardDAV account, then looked at Finder's recently modified files. This is what I found, and there are probably more:

  • a new folder in ~/Library/Application Support/AddressBook/Sources/ containing 4 files and a Metadata folder
  • a new plist file in ~/Library/LaunchAgents/
  • a new plist file in ~/Library/Containers/com.apple.mail/Data/Library/LaunchAgents/
John Sauer
  • 4,411
  • 1
  • 25
  • 33