Applescript 的替代品? [英] Alternatives to Applescript?

查看:33
本文介绍了Applescript 的替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写 Mac 脚本时,是否有 Applescript 的替代方案?它的 API 看起来很棒,但从我目前所读到的内容来看,语言本身似乎更针对非程序员.

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.

(目前,我正在考虑为 Mac 编写一个平铺窗口管理器.是的,我知道有些存在,但这将是开源的.是的,我知道 Xmonad,但它只支持 X11 窗口.)

(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.)

谢谢!

推荐答案

在编写 Mac 脚本时,是否有 Applescript 的替代品?

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

取决于你想做什么.如果您想将 Apple 事件发送到其他应用程序,是的;用于从支持 OSA 的应用程序(邮件规则、文件夹操作等)运行脚本,实际上并非如此.

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.

最好的技术替代方案是 appscript(我的宝贝),它可用于 Python、Ruby 和 Objective-C 10.4+.(还有一个 MacRuby 版本,但我还没有公开发布它.)功能方面的 appscript 比 AppleScript 稍好一些,而且它的应用程序兼容性几乎一样好.第三方项目,所以你需要自己安装它(但只要你有 Xcode,这很容易)和 MIT 许可,以便你可以根据需要重新分发它(例如包含在你的应用程序包中).相当不错的工具和文档支持,包括一个在线书籍 作者:Matt Neuburg,提供对 Python 和 Ruby 版本的邮件列表支持以及对其他版本的直接电子邮件支持.

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.

官方"替代方案是 Apple 的 脚本桥.API 看起来很像 Cocoa,但实际上只是很多烟雾和镜像,这最终使其功能不如 AppleScript,并且更容易出现应用程序兼容性问题(并且在出现问题时很难进行故障排除).工具、文档和社区支持也不是很好(appscript 的更好;AppleScript 的更好).SB 的主要优点是它包含在 10.5+ 中,因此无需额外安装即可使用.由于其技术缺陷,我不建议将其用于繁重的自动化工作,但对于涉及强制应用程序的适度自动化任务,它可能就足够了.

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.

其他桥接器确实存在(例如 Perl 的 Mac::Glue、RubyOSA),但它们的功能、流行和/或积极支持.

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

综上所述,如果您想编写任何严肃的应用程序脚本,您仍然需要学习 AppleScript,因为在那里您可以找到大量文献、示例脚本和社区专业知识.您将需要所有这些,因为众所周知,大多数可编写脚本的应用程序文档不足.

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.

这篇关于Applescript 的替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆