jeudi 18 janvier 2018

Send random image via iMessage in AppleScript

I'm trying to send a random image from the "lv" folder on the desktop via iMessage.

tell application "Finder"
        set theFile to some file of folder "Macintosh HD:Users:user:Desktop:lv:"
    end tell

set randomImage to POSIX file theFile

tell application "Messages"

    set targetBuddy to "appleid@mac.com"

    set targetService to id of 1st service whose service type = iMessage

    set textMessage to randomImage

    set theBuddy to buddy targetBuddy of service id targetService

    send textMessage to theBuddy

end tell

Using

tell application "Preview"
open theFile
end tell

I can tell that the random image works. But it's not passed to iMessage. The error message says that the "expected type can't be converted". Error code -1700

Thanks for any suggestions!




Aucun commentaire:

Enregistrer un commentaire