Created
September 16, 2022 16:30
-
-
Save stringsn88keys/70fb7e0cf73a987f3d41e060820c9c97 to your computer and use it in GitHub Desktop.
Send an iMessage from the command line (one arg at a time)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript | |
# https://chrispennington.blog/blog/send-imessage-with-applescript/ | |
on run parameters | |
# the number here is the number of seconds | |
set theDelay to 3 | |
# Verify if this can use display names | |
set phoneNumber to "+1 (555) 555-1212" | |
tell application "Messages" | |
set targetBuddy to phoneNumber | |
set targetService to id of 1st account whose service type = iMessage | |
repeat with a from 1 to length of parameters | |
set textMessage to ( item a of parameters ) | |
set theBuddy to participant targetBuddy of account id targetService | |
send textMessage to theBuddy | |
delay theDelay | |
end repeat | |
end tell | |
log "Message sent" | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment