Skip to content

Instantly share code, notes, and snippets.

@homam
Last active December 23, 2020 09:51
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save homam/0119797f5870d046a362 to your computer and use it in GitHub Desktop.
Save homam/0119797f5870d046a362 to your computer and use it in GitHub Desktop.
AppleScripts for sending iMessages and Attachment
osascript send-imessage.scpt "hello" "Homam Hosseini"
osascript send-imessage-pic.scpt `realpath northamerica-neb.jpg` "Homam Hosseini"
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
on run argv
set filename to item 1 of argv
set buddyName to item 2 of argv
set attach to POSIX file filename
tell application "Messages" to send attach to buddy buddyName
end run
on run argv
set message to item 1 of argv
set chatNumber to item 2 of argv as integer
tell application "Messages" to send message to item chatNumber of text chats
end run
@Mastermark2015
Copy link

when i run this i get Can’t get item 2. Invalid index.
Can u help a little as learning

@boygiandi
Copy link

I can't send image. Please check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment