开发者

Can an applescript "tell" call execute without visibly launching the application?

开发者 https://www.devze.com 2023-02-11 23:33 出处:网络
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

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"
        -开发者_StackOverflow- 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消