Skip to content

Instantly share code, notes, and snippets.

@ajitam
Last active May 17, 2018 06:33
Show Gist options
  • Save ajitam/dcf16641ff0b9a221dc44f52d0f86611 to your computer and use it in GitHub Desktop.
Save ajitam/dcf16641ff0b9a221dc44f52d0f86611 to your computer and use it in GitHub Desktop.
-- Send iMesage with AppleScript
-- @description This script open Messages application and sends iMessage to
-- specific apple id.
--
-- @note Before run go to Messages and create the conversation (aka. send one
-- message)
--
-- @run osascript sendAppleMessage.applescript "user@email.com" "This is an iMessage send from applescript"
on run {sndAppleID, sndMessage}
tell application "Messages"
-- get and set myAppleID
set myAppleID to get id of first service
-- set receiver
set receiver to buddy sndAppleID of service id myAppleID
-- send message
send sndMessage to receiver
-- hide the window
tell application "System Events" to set visible of process "Messages" to false
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment