使用 Ruby 而不是 AppleScript 使 Cocoa 应用程序可编写脚本
是否可以使用 Ruby 而不是 AppleScript 使 Cocoa 应用程序可编写脚本?我有什么理由不应该这样做吗?
即使必须使用 AppleScript,仍然有以下替代方案:
- AppleScript 字典仅包含一个“函数”:“sendRubyScriptToApp”。这个“函数”(不确定它们在 AppleScript 中的名称)的作用是简单地传递一个包含应用程序接受的整个 Ruby 脚本的字符串。
- 以常规方式使用 AppleScript。
有哪些优点和缺点?
Is it possible to make a Cocoa app scriptable using Ruby instead of AppleScript? Any reasons why I shouldn't?
Even if one has to use AppleScript, there are still the following alternatives:
- The AppleScript dictionary only contains one "function": "sendRubyScriptToApp". What this "function" (not sure what they're called in AppleScript) does is to simply pass a string containing the entire Ruby script that the app accepts.
- Use AppleScript in the regular way.
What would be some advantages and drawbacks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为违背 AppleScript 的原则有很多缺点。主要是因为您必须在应用程序中嵌入 ruby 运行时才能使您的想法发挥作用。我建议以常规方式使用 AppleScript,然后使用 rb-appscript 为您的应用程序编写脚本。 Rb-Appscript 将允许您创建通过 AppleScript 与您的应用程序交互的 ruby 代码。
I think there are many disadvantages of going against the grain with AppleScript. Mainly because you have to then embed a ruby runtime in your application to get your idea to work. I suggest using AppleScript the regular way and then using rb-appscript to script your app. Rb-Appscript will allow you to create ruby code that interfaces with your application via AppleScript.