Can System Events tell delicious2safari to click its own button?

I’m trying to write a simple applescript that can interact with the delicious2safari user interface. The current distribution of delicious2safari does not automatically sync your delicious bookmarks with Safari, like the delicious add-on for Firefox does. If you want to keep your bookmarks on Safari up-to-date, you have to run delicious2safari each time you change your delicious bookmarks. I want automate the process of interacting with the application so I can set up a schedule in iCal to handle it for me.

Here’s what I have:

launch application "delicious2safari"

tell application "System Events"
	tell window "delicious2safari"
		click button "Get my bookmarks!"
	end tell
end tell

I run it, and System Events gets this error: “NSReceiverEvaluationScriptError: 4” which I understand means that it probably can’t even find the button “Get my bookmarks!”

Any suggestions?

Model: MacBook
AppleScript: 1.10.7
Browser: Firefox 2.0.0.11
Operating System: Mac OS X (10.4)

Hi,

first: the application to talk to must be frontmost, so launch isn’t sufficient.
second: the UI element are always parts of the process of the application

I don’t use delicious2safari, but try this


activate application "delicious2safari"
tell application "System Events"
	tell process "delicious2safari"
		tell window "delicious2safari"
			click button "Get my bookmarks!"
		end tell
	end tell
end tell

Nope. Same error.

I’ve just downloaded it.
It’s this

activate application "delicious2safari"
tell application "System Events"
	tell process "delicious2safari"
		click button "Get my bookmarks!" of group 1 of window "delicious2safari"
	end tell
end tell

Works like a charm. Thanks very much.

If you don’t mind one more question: why do we need to specify group 1 of the window?

Because the author added a tab view UI element in the main window, although it’s actually not needed.