Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to Applescript? [closed]

Tags:

applescript

When it comes to scripting the Mac, are there alternatives to Applescript? Its API seems awesome, but the language itself, from what I've read so far, seems aimed more at non-programmers.

Insights into this would be greatly helpful.

(At the moment, I'm thinking of writing a tiling window manager for the Mac. Yes, I know some exist, but this will be open source. Yes, I know of Xmonad, but it only does X11 windows.)

Thanks!

like image 914
anon Avatar asked Jan 29 '10 19:01

anon


People also ask

What is replacing AppleScript?

Using Swift.

Can Python replace AppleScript?

Python can't be used to replace the UI & automation duties that AppleScript offers. However since OS X 10.10 (Yosemite) JavaScript can also be used. The AE modules in Python 2.

Is Swift replacing AppleScript?

There are not Swift replacements for AppleScript application dictionary support. Apple continues to tweak AppleScript, so it isn't dead yet. And I continue to write ASOC applications.

Does Apple still use AppleScript?

AppleScript is a scripting language created by Apple Inc. that facilitates automated control over scriptable Mac applications. First introduced in System 7, it is currently included in all versions of macOS as part of a package of system automation tools.


1 Answers

When it comes to scripting the Mac, are there alternatives to Applescript?

Depends what you want to do. If you want to send Apple events to other applications, yes; for running scripts from OSA-aware applications (Mail rules, folder actions, etc.), not really.

The best technical alternative is appscript (my baby), which is available for Python, Ruby and Objective-C on 10.4+. (There's also a MacRuby version, but I've yet to do a public release of that.) Feature-wise appscript's slightly better than AppleScript and its application compatibility is very nearly as good. Third-party project, so you'll need to install it yourself (but that's easy enough as long as you've got Xcode) and MIT licensed so you can redistribute it as needed (e.g. included in your application bundle). Fairly decent tool and documentation support, including an online book by Matt Neuburg, with mailing list support for the Python and Ruby versions and direct email support for the others.

The 'official' alternative is Apple's Scripting Bridge. The API looks very Cocoa-like, but that's really just a lot of smoke and mirrors which ultimately makes it less capable than AppleScript and significantly more prone to application compatibility problems (and tricky to troubleshoot when it does go wrong). Tool, documentation and community support is not so great either (appscript's is better; AppleScript's is better still). SB's main advantage is that it's included in 10.5+ so requires no additional installation to use. I wouldn't recommend it for heavy-duty automation work due to its technical shortcomings, but for modest automation tasks involving obliging apps it may suffice.

Other bridges do exist (e.g. Perl's Mac::Glue, RubyOSA), but they are not as capable, popular and/or actively supported.

All that said, if you want to do any serious application scripting, you will still have to learn AppleScript as that's where you'll find the vast bulk of literature, sample scripts and community expertise. All of which you will need, since the great majority of scriptable applications are notoriously under-documented.

like image 118
has Avatar answered Dec 19 '22 00:12

has