本文介绍了如何仅在提供的服务中使用applescript 发送imessage 文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我如何通过消息应用直接向 iMessage 用户发送消息?
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
我只需要通过 iMessage 向帐户发送消息,而不是通过 google talk、AIM、bonjour.谢谢!
I need to send a message to an account only via iMessage, not via google talk, AIM, bonjour.Thank you!
推荐答案
无需对 iMessage 服务进行硬编码,您可以自动找到它:
Instead of having to hard-code the iMessage service, you can find it automatically:
- 将以下脚本另存为
sendMessage.applescript
(注意:确保选择 Text 选项). - 通过运行执行它:
osascript sendMessage.applescript 1235551234 "Hello there!"
. - 这会向电话号码 123-555-1234 发送一条包含文本你好!"的 iMessage.
- Save the following script as
sendMessage.applescript
(Note: make sure to choose the Text option). - Execute it by running:
osascript sendMessage.applescript 1235551234 "Hello there!"
. - This will send an iMessage to the phone number 123-555-1234 containing the text "Hello there!".
sendMessage.applescript:
on run {targetBuddyPhone, targetMessage}
tell application "Messages"
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
send targetMessage to targetBuddy
end tell
end run
这篇关于如何仅在提供的服务中使用applescript 发送imessage 文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!