使用 Ruby 而不是 AppleScript 使 Cocoa 应用程序可编写脚本

发布于 2024-12-18 05:01:51 字数 288 浏览 3 评论 0原文

是否可以使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深已缘浅 2024-12-25 05:01:51

我认为违背 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文