Trying to script Facebook through Safari with GUI scripting

Hello, I am trying to manipulate Facebook pages in various ways, which is tricky since there’s little or no support for this sort of thing from Facebook. I’m trying to do GUI scripting to simulate what I would type into the Facebook site itself. It’s tricky, since Facebook is so “Ajax-ey” and doesn’t use any of the old Put or Get forms which can be scripted somewhat through Javascrpt. The main challenge I’m having is reliably pressing the “submit” button to make wall posts on Facebook, after my script has entered some data that I want it to type. The only success I’ve had with this at all is using Automator to record an action to click “Submit” for me, but it fails 50% of the time for no reason that I can see.

So my question is, is there a “modern” way of scripting GUI (I presume) directly so that, say, the first button that says “submit” can be clicked reliably? Or if there’s a better way of doing this any suggestions would be great, too.

A way to click into the top text field (which contains the text “Type something…”) on a Facebook “wall” would be good too, although I am faking it by typing the tab key through GUI scripting.

Model: Macbook Pro
Browser: Safari 534.13
Operating System: Mac OS X (10.6)

Though I never do any web/Safari driving stuff, as a user it seems like FB tweaks their pages often enough I would never want to rely on the page to do any of that stuff.
Don’t they have some kind of API to communicate directly with their site? Maybe there’s some Objective C you could use.

don’tuse gui scripting in Safari at all. Everything in your page can be done with javascript and therefore can make those facebook ajax calls yourself if you like.

Thanks, got any good websites or guides on how to do that, e.g. click a button through Javascript? Being overly dependent on AS I never properly learned Javascript.

I’ve played around with this and asked on another forum, and was told it was difficult/impossible to do with javascript as Facebook is an iframe located on their server, hence the entire source isn’t usable to the browser. It’s all so complex. The main thing I need to do is be able to click the Submit button after typing some text, which I can do well. Any method will do – I even got it to work a while with Automator, although it’s not reliable enough to trust. Can anyone suggestion a reliable way to click that one button after text has been entered through any browser (Safari preferably, but whatever will work).

How about Sikuli and Applescript?

I actually got it to work, using the program UI Browser, which lets you mouse over an object, and it tells you what the path is to the object, and even builds beginning scripts for you. Fabulous app, I recommend it. What I ended up with, to click the Share button in Facebook, was as follows:

tell application "System Events"
	tell process "Safari"
			click button "Share" of group 1 of group 2 of list 3 of group 9 of UI element 1 of scroll area 1 of group 3 of window thename -- this one works on the mini?
		on error
			click button "Share" of group 1 of group 2 of list 3 of group 9 of UI element 1 of scroll area 1 of group 2 of window thename -- did not work
		end try
	end tell

(the same page reported different UI locations on two different computers, which is why I put both in, in case it changed on me sometime).

So far it’s been quite reliable.