AppleScript可以在不明显启动应用程序的情况下执行“告诉”调用执行?

StackOverflow https://stackoverflow.com/questions/5033447

  •  14-11-2019
  •  | 
  •  

我有一个邮件规则设置以启动以下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
.

只要执行此邮件规则,它就会启动地址簿。它没有激活,但它突然在我的桌面上显示。我的问题是,可以告诉块被指示默默地启动应用程序,并在完成时退出?

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top