applescript 可以“告诉”吗?调用执行而不明显启动应用程序?
我设置了一个邮件规则来启动以下 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果应用程序不运行,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.
要在不启动“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.