如何使用AppleScript发送图片

时间:2018-10-24 18:07:02

标签: applescript imessage

我制作了一个向人们发送消息的脚本。我也希望能够通过此脚本发送图片。

on run
    tell application "Messages"
        set targetService to 1st service whose service type = iMessage
        set targetBuddy to buddy "18008888888" of targetService

        repeat 3 times
            send "/Users/ADMIN/Desktop/photo.png" to 
targetBuddy
        end repeat

    end tell
end run

将照片目录放入报价单中会使发送的消息成为字符串,而删除报价单则会导致错误。

1 个答案:

答案 0 :(得分:1)

您需要一个file参考。试试

send POSIX file "/Users/ADMIN/Desktop/photo.png" to targetBuddy

set filePath to (path to desktop as text) & "photo.png"

tell application "Messages"
    set targetService to 1st service whose service type = iMessage
    set targetBuddy to buddy "18008888888" of targetService

    repeat 3 times
        send file filePath to targetBuddy
    end repeat
end tell
相关问题