[ann] Ruby appscript 0.1.1 released

Announcing the first public release of Ruby appscript, a high-level,
user-friendly Apple event bridge that allows you to control scriptable
Mac OS X applications using ordinary Ruby scripts.

http://rb-appscript.rubyforge.org/

Appscript makes Ruby a serious alternative to Apple's own AppleScript
language for automating your Mac. Here's a quick example:

require "appscript"

AS.app('TextEdit').documents.end.make(
    :new => :document,
    :with_properties => {:text => "Hello World!\n"})

Ruby appscript is a port of the popular Python appscript package
<http://appscript.sourceforge.net/>, so while this initial release may
lack a little polish in places, it's based on a mature, well-proven
architecture that has been developed, tested and refined over several
years. As a result, rb-appscript 0.1.1 offers a level of power,
robustness and performance that is already very close to
py-appscript's, with further improvements to come.

The rb-appscript package includes additional example scripts,
documentation and a tutorial, and can be downloaded from:

http://rubyforge.org/frs/?group_id=2346

Forums for discussing rb-appscript are also available. Questions, bug
reports, suggestions for improvements, etc. will all be very welcome.

Enjoy!

Could you explain what the differences are with ruby aeosa? Below is an example from the website:

require 'osx/aeosa'
app = OSX::AEDesc.application "Internet Explorer"
app.open_docs "html/INDEX.en.html"
app.activate
app.quit_app

http://www.fobj.com/rubyaeosa/

···

On Oct 11, 2006, at 3:35 PM, has.temp3@virgin.net wrote:

Appscript makes Ruby a serious alternative to Apple's own AppleScript
language for automating your Mac. Here's a quick example:

require "appscript"

AS.app('TextEdit').documents.end.make(
    :new => :document,
    :with_properties => {:text => "Hello World!\n"})

rb-appscript-0.1.2 has just been posted:

http://rubyforge.org/frs/?group_id=2346&release_id=7361

This release fixes a bug where enumerator values returned by
applications were being unpacked incorrectly.

Ryan Davis wrote:

Could you explain what the differences are with ruby aeosa?

Appscript is a much, much higher-level bridge for creating and sending
Apple events. Constructing complex commands and references in aeosa
requires a detailed understanding of the low-level Apple Event Manager
API and lots and lots of grungy code.

For example, just getting the text of the front TextEdit document in
aeosa involves writing:

require 'osx/aeosa'

app = OSX::AEDesc.application("TextEdit")
app.ae_send_mode = 3

query = OSX::AEDesc.record({
  'want' => OSX::AEDesc.new('type', 'prop'),
  'form' => OSX::AEDesc.new('enum', 'prop'),
  'seld' => OSX::AEDesc.new('type', 'ctxt'),
  'from' => OSX::AEDesc.record({
      'want' => OSX::AEDesc.new('type', 'docu'),
      'form' => OSX::AEDesc.new('enum', 'indx'),
      'seld' => 1,
      'from' => OSX::AEDesc.null})}).coerce('obj ')

p app.ae_send('core', 'getd', query).coerce('reco').
to_rbobj['----'].to_rbobj

Pretty hairy stuff (and even after a half-hour's troubleshooting I
still couldn't get it to work correctly for some reason).

With appscript, you just write:

require "appscript"

p AS.app("TextEdit").documents[1].text.get

Constructing the application object model query, translating
human-readable terminology to four-character codes, and packing and
unpacking Ruby values is all handled automatically, and the whole lot's
wrapped up in a very user-friendly OO-like syntax.

HTH