hengist podd
10/12/2006 12:16:00 AM
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