Welcome to the VBAX Zone, Mac-style!

I think AppleScript is the way to do it (perhaps also Perl and Python - both available in OS X). However, I have not moved in that direction. I will look for resources for you.

Also, maybe BlueCactus has some ideas.