告诉 Mail.app 使用 MacRuby 检查新邮件

发布于 2024-12-28 12:27:29 字数 444 浏览 5 评论 0原文

我想使用 MacRuby 告诉 Mail.app 检查新电子邮件。但在使用 SBApplication 获得应用程序参考后,我不知道如何解决这个问题。

我有以下简单的脚本:

#!/usr/local/bin/macruby
framework 'ScriptingBridge'

mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail")
# mail.check_for_new_mail?

基本上我想在 MacRuby 中执行以下 AppleScript:

tell application "Mail"
    check for new mail
end tell

是的,我可以只使用 AppleScript。但我更喜欢Ruby。

I want to use MacRuby to tell Mail.app to check for new email. But I cannot figure out how to go about this after I get an application reference using SBApplication.

I have the following simple script:

#!/usr/local/bin/macruby
framework 'ScriptingBridge'

mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail")
# mail.check_for_new_mail?

Basically I want to do the following AppleScript in MacRuby:

tell application "Mail"
    check for new mail
end tell

Yes, I can just use the AppleScript. But I much prefer Ruby.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

韵柒 2025-01-04 12:27:29
#!/usr/local/bin/macruby
framework 'ScriptingBridge'

mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail")
mail.accounts.each {|account| mail.checkForNewMailFor(account) }

提示:使用puts (mail.methods(true,true) - Object.new.methods)返回对象和祖先可用的仅可可方法列表

#!/usr/local/bin/macruby
framework 'ScriptingBridge'

mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail")
mail.accounts.each {|account| mail.checkForNewMailFor(account) }

tip: use puts (mail.methods(true,true) - Object.new.methods) which returns available cocoa only methods list for object and ancestors

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