appscript

About rb-appscript

Please note that appscript is no longer developed or supported, and its use is not recommended for new projects.

Ruby appscript (rb-appscript) is a high-level, user-friendly Apple event bridge that allows you to control scriptable Mac OS X applications using ordinary Ruby scripts.

For example, to get the value of the first paragraph of the document named "ReadMe" in TextEdit:

app('TextEdit').documents['ReadMe'].paragraphs[1].get

This is equivalent to the AppleScript statement:

tell application "TextEdit"
    get paragraph 1 of document "ReadMe"
end tell

Rb-appscript requires Ruby 1.8+ and Mac OS X 10.4 or later.

Matt Neuburg has written a book about rb-appscript: Scripting Mac Applications With Ruby: An AppleScript Alternative.

Notes

Ruby appscript (rb-appscript) is a port of the original py-appscript bridge. There are a few minor syntax and API changes to accomodate the differences between the two languages, but they are otherwise very similar.

Please note that while rb-appscript uses regular object-oriented Ruby syntax, because it's a bridge to the query-driven Apple Event Manager there are some differences in how it behaves. Check the appscript manual for more information.

Rb-appscript does not work with MacRuby. A separate macruby-appscript bridge can be obtained from the appscript repository (note: also requires objc-appscript):

svn checkout \
    https://appscript.svn.sourceforge.net/svnroot/appscript/macruby-appscript/trunk \
    macruby-appscript-trunk