views:

38

answers:

2

I already do a lot with shell scripts on the Mac, but I loathe AppleScript, and I would love to be able to access Mac apps' APIs in some other way. Does anyone know any other way to get the power of AppleScript without the pain of its horrible syntax and meager documentation (and its slowness, if possible)?

+3  A: 

appscript is probably your best bet - there are variants for Python or Ruby which should fit well into shell scripts.

There'll still be some trial and error in dealing with individual applications' vocabularies, which you can't really do much about, but at least you'll have a far more capable language (or two) to wrap around it.

Nicholas Riley
Thanks, appscript looks like just what I need.
Robusto
+1  A: 

What about MacRuby? It isn't exactly shell scripting but it's not so far removed (and, arguably, much nicer).

Also not sure about the Applescript APIs specifically (not checked) but with HotCocoa you basically have access to Cocoa.

I've pinched this code snippet from here but as you can see it is very readable (this is code just to display a hello world window, admittedly not a typical scripting operation):

require 'hotcocoa'
include HotCocoa

application do |app|
 win = window :size => [100,50]
 b = button :title => 'Hello'
 b.on_action { puts 'World!' }
 win << b
end

Caveat - MacRuby is at v0.6 but is generally stable in my limited usage. Not exactly what you asked for but might be worth a look anyway.

macbutch