applescript 可以“告诉”吗?调用执行而不明显启动应用程序?

发布于 2024-10-17 22:28:44 字数 571 浏览 1 评论 0原文

我设置了一个邮件规则来启动以下 applescript:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"

            -- do stuff, including...
            CheckAddressBook(theName, theAddress)

        end tell
    end perform mail action with messages
end using terms from

on CheckAddressBook(theName, theAddress)
    tell application "Address Book"
        -- do stuff
    end tell
end CheckAddressBook

每当此邮件规则执行时,它都会启动地址簿。它没有激活,但它突然出现在我的桌面上。我的问题是,是否可以指示告诉块以静默方式启动应用程序,并在完成后退出?

I have a Mail rule set up to launch the following applescript:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"

            -- do stuff, including...
            CheckAddressBook(theName, theAddress)

        end tell
    end perform mail action with messages
end using terms from

on CheckAddressBook(theName, theAddress)
    tell application "Address Book"
        -- do stuff
    end tell
end CheckAddressBook

Whenever this mail rule executes, it launches address book. Its not activated, but it suddenly shows up on my desktop. My question is, can tell blocks be instructed to launch the application silently, and quit when complete?

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

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

发布评论

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

评论(2

又怨 2024-10-24 22:28:44

如果应用程序不运行,AppleScript 就无法对其进行控制。这就是它的工作原理。您可以使用其他方法来访问地址簿数据库而不启动应用程序,但如果您使用 AppleScript 从地址簿数据库获取数据,则必须启动应用程序。我的建议是按照 Fábio 的建议简单地添加一个退出命令。

AppleScript can't control an application without it running. That's just the way it works. There are other methods you might use to access the Address Book database without launching the application, but if you're using AppleScript to get data from your Address Book database the application has to launch. My recommendation would be to simply add a quit command as suggested by Fábio.

被你宠の有点坏 2024-10-24 22:28:44

要在不启动“Address Book.app”的情况下读取地址簿数据库,我建议您查看免费的命令行工具“contacts”此处。然后,您可以从 Applescript 运行它,例如 do shell script "/usr/bin/contacts Peter" 并处理返回的值。

To read the Address Book Database without launching "Address Book.app" I´d suggest to have a look at the command line tool "contacts" available for free here. You would then run it from Applescript like do shell script "/usr/bin/contacts Peter" and handle the values returned.

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