Apple Script - send (insert screenshot from clipboard?) & theTime to imessagebuddy I have an automator workflow starting with "Take ScreenShot" to take screenshot and paste to clipboard.

Following that I have

set theTime to time string of (current date)

tell application "Messages"
    set iMessageService to 1st service whose service type = iMessage
    set imessagebuddy to buddy "imessagebuddy@domain.com" of iMessageService
    send theTime to imessagebuddy
end tell


I want to include the screenshot in the message with the time.
Here is a way to take the screenshot from the clipboard and send it in Messages.

Example AppleScript code:

if ((clipboard info) as string) contains JPEG picture then

    set jpgData to the clipboard as JPEG picture        
    set fileName to "/tmp/IMG_" &amp; (random number from 1000 to 9999) &amp; ".JPG" as string

    try
        set thisFile to open for access POSIX file fileName with write permission
        write jpgData to thisFile
        close access thisFfile
    on error
        close access thisFile
        return
    end try

    set theTime to time string of (current date)
    set thePicture to POSIX file fileName as alias

    tell application "Messages"
        set iMessageService to 1st service whose service type = iMessage
        set imessagebuddy to buddy "imessagebuddy@domain.com" of iMessageService
        send theTime to imessagebuddy
        send thePicture to imessagebuddy
    end tell

    tell application "System Events"
        delete alias fileName
    end tell

end if




Note: The example AppleScript code is just that and does not employ any other error handling then what's shown and is meant only to show one of many ways accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.