MacRuby for Application Scripting
MacRuby 0.6 was released a few days ago (30 April 2010). MacRuby is a version of Ruby 1.9, ported to run on the Mac OS X Objective-C common runtime. You can write Cocoa apps and, interestingly, you can also use ruby as a scripting language to control applications running on your system.
The MacRuby install includes macirb, the MacRuby equivalent of Ruby’s irb command line interpreter.
Here is an example script to read from and control iTunes via the scripting bridge.
Here is an example script for Photoshop.
photoshop = SBApplication.applicationWithBundleIdentifier('com.adobe.photoshop')
To see a list of what methods are available for an object, call its methods method as follows, subtracting out the methods available to Object.
photoshop.methods(true,true) - Object.methods(true,true)
Pretty cool stuff. I was never a big fan of AppleScript, and in fact stayed away from scripting Mac applications because I didn’t like using AppleScript. This, to me, changes the equation.