Q: Sending Images via iMessage with AppleScript
Using AppleScript to send a message via iMessage, I can send plain text just fine. However, when I try to send a file, Applescript wants to send it using colon delimited paths and Messages doesn't understand how to interpret that.
#Capture an image of the main room camera
set {year:y, month:mo, day:d, hours:h, minutes:mi, seconds:s} to (current date)
set theFile to "/Users/ladmin/Documents/MotionAlarm/AlarmImages/" & y & "-" & mo & "-" & d & "-" & h & "-" & mi & "-" & s & ".jpg"
set theAttachment to POSIX path of theFile
tell application "SecuritySpy" to capture image as theFile camera number 1
delay 5
#Send that image via iMessage
using terms from application "Messages"
tell application "Messages"
set myid to get id of second service
set theBuddy to buddy "buddy@me.com" of service id myid
send "Motion detected!" to theBuddy
send file theAttachment to theBuddy
end tell
end using terms from
You get the following error in Console:
4/30/13 10:44:52.262 PM imagent[539]: [Warning] Linking failed with error Error Domain=NSCocoaErrorDomain Code=260 "The file “/Users/ladmin/Documents/MotionAlarm/AlarmImages/2013-April-30-22-44-46.jpg” couldn’t be opened because there is no such file." UserInfo=0x7ff9cac51050 {NSFilePath=/:Users:ladmin:Documents:MotionAlarm:AlarmImages:2013-April-30-22-4 4-46.jpg, NSUnderlyingError=0x7ff9cac34760 "The operation couldn’t be completed. No such file or directory"}
Any suggestions?
Posted on Apr 30, 2013 8:50 PM
Check this out, maybe this can point you in the right direction:
Posted on Apr 30, 2013 10:11 PM