Alternatives to Applescript? [closed]

断了今生、忘了曾经 提交于 2020-01-01 02:41:29

问题


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!


回答1:


If Ruby is your thing you could use RubyOSA which allows one to use Ruby to interact with Apple's Event Manager:

http://rubyosa.rubyforge.org/




回答2:


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.




回答3:


Check out MacRuby. There are also interesting approaches with Python (mainly for writing plugins) and TCL/TK.

Maybe not the thing for the purpose you describe, but there also is Quartz Composer, a widely unknown but interesting visual programming environment with a lot of potential.




回答4:


There are bridges to AppleScript from ruby, objective-c and others.



来源:https://stackoverflow.com/questions/2164410/alternatives-to-applescript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!