Can somebody show me how to send a message directly to the user of iMessage via Messages app?
tell application "Messages"
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 1
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 2
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 3
send "Message" to buddy "mail of name" of service x
end tell
I need to send a message to an account only via iMessage, not via google talk, AIM, bonjour. Thank you!
As far as I do understand it you cannot start a new conversation via AppleScript. Thus the Buddy and the service must fit together and must have an ongoing conversation.
If you have the name of the buddy you could do the following
This will return the service name that fits to the buddy. Of course you could also use the the service id. But I like to use the name.
In the end you will be able to send a message with
I had the same question and after some searching I found the answer. In order for the "first service" to be iMessage you will need to go into iMessage Preferences Accounts and re-order the iMessage account to be the first one. After that this works like a charm.
This will also start a conversation if there is not one existing.
Hope that helps!
This script will send a message every 10~30 seconds
Examples:
Your line:
seems to work if "buddy" and "service" is valid.
I have my iMessage with my Apple-ID registered, so when I execute "get name of services" I get for this service a string like
which I can use for "service". Buddy is just the name of your buddy, also as pure text. See "get name of buddies".
Hope it works!
Instead of having to hard-code the iMessage service, you can find it automatically:
sendMessage.applescript
(Note: make sure to choose the Text option).osascript sendMessage.applescript 1235551234 "Hello there!"
.sendMessage.applescript:
Ok, I just made the following into an Automator action which grabs the logged in user´s full name, finds the matching iPhone number from Contacts, the service name, and lastly it sends the incoming text (from the previous action) to...myself on iMessage. Not very useful, at least to me at the moment, but I proved it to be possible in a way :)