writing an automator workflow for backing up the address book

Hi,

I am trying to write an automator workflow to run the “Back up Address Book” command in address book (I was planning to just write an automator scipt, and have iCal run it every morning), but I seem to have a small problem:

So in the automator workflow, I first run the 'Launch Application" action, and select Address Book. Then I selected the “Run Applescript” Action, and I used the following script:

on run {input, parameters}

tell application "System Events"
    tell process "Address Book"
        tell menu bar 1
            click menu item "Back up Address Book..." of menu "File"
        end tell
    end tell
end tell

return input

end run

I am able to ‘close’ the window, run the ‘minimize’ command from the window menu, and do other little things, but for some reason, the ‘Back up Address Book’ command does not work. Please help!

am I typing in “Back up Address Book…” properly?

The menu item uses an ellipsis character (Option-;), not three periods as you have used. The easiest way to have solved this was to use a command that gets the menu item names and then copy and paste. So, for instance, this would get the names of the menu items of the File menu:

tell application "Address Book" to activate
tell application "System Events"
	tell process "Address Book"
		tell menu bar 1
			return name of menu items of menu "File"
			-->{"New Card", "New Group", "New Group From Selection", "New Smart Group.", missing value, "Close", "Save", missing value, "Import", "Export vCard.", missing value, "Back up Address Book.", "Revert to Address Book Backup.", missing value, "Subscribe to Address Book.", missing value, "Send Updates.", missing value, "Print."}
		end tell
	end tell
end tell

Then, copy and paste and you get:

tell application "Address Book" to activate
tell application "System Events"
	tell process "Address Book"
		tell menu bar 1
			click menu item "Back up Address Book." of menu "File"
		end tell
	end tell
end tell

Jon

Thanks for the reply! I was able to follow your directions, and the scipt works uptil a point, but then the address book program wants me to click on the ‘SAVE’ button. Is there a way to tell applescript to automatically select the SAVE option. Also, can you recommend a good book (or website) so I can learn applescript commands?

Thanks!

-V-

Please take a look at the iCal database backup script. iCal and Address Book both have “Back up database”, so your solution may be there.

http://bbs.applescript.net/viewtopic.php?id=14605