[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ann] Ruby appscript 0.1.1 released

hengist podd

10/11/2006 10:30:00 PM

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.ruby...

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.sourceforg..., 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/?gro...

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

Enjoy!

3 Answers

Ryan Davis

10/11/2006 10:52:00 PM

0


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"})

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/...




hengist podd

10/12/2006 12:16:00 AM

0


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

hengist podd

10/12/2006 4:31:00 PM

0

rb-appscript-0.1.2 has just been posted:

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

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