web-dev-qa-db-ja.com

提供されたサービスでのみ、AppleScriptでiMessageテキストを送信するにはどうすればよいですか?

メッセージアプリを介してiMessageのユーザーにメッセージを直接送信する方法を教えてもらえますか?

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

Googleトーク、AIM、bonjourではなく、iMessageを介してのみアカウントにメッセージを送信する必要があります。ありがとうございました!

18
cre8eve

IMessageサービスをハードコーディングする代わりに、自動的に見つけることができます。

  1. 次のスクリプトをsendMessage.applescriptとして保存します(注:必ずTextオプションを選択してください)。
  2. osascript sendMessage.applescript 1235551234 "Hello there!"を実行して実行します。
  3. これにより、「Hello there!」というテキストを含む電話番号123-555-1234にiMessageが送信されます。

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
45
Senseful

私の知る限り、AppleScriptを介して新しい会話を開始することはできません。したがって、バディとサービスは互いに適合し、継続的に会話する必要があります。

あなたがバディの名前を持っているなら、あなたは次のことができます

tell application "Messages"
    get name of service of buddy "Buddy Name"
end tell

これにより、バディに適合するサービス名が返されます。もちろん、サービスIDを使用することもできます。しかし、私は名前を使うのが好きです。

最後に、メッセージを送信できるようになります

tell application "Messages"
    send "Text of Message" to buddy "+43 555 XXXXXXX" of service "E:[email protected]"
end tell
9
Touri

このスクリプトは10〜30秒ごとにメッセージを送信します

tell application "Messages"

    set targetBuddy to "+12025551234"
    set targetService to id of 1st service whose service type = iMessage

    repeat

        set textMessage to "Hi there!"

        set theBuddy to buddy targetBuddy of service id targetService
        send textMessage to theBuddy

        delay (random number from 10 to 30)

    end repeat

end tell
7
Vitim.us
tell application "Messages"
    set myid to get id of first service
    set theBuddy to buddy "[email protected]" of service id myid
    send "Washer Done!" to theBuddy
end tell

私は同じ質問をしました、そして、いくらかの調査の後、私は答えを見つけました。 「最初のサービス」をiMessageにするには、iMessage Preferencesアカウントに移動し、iMessageアカウントを最初のアカウントに再注文する必要があります。その後、これは魅力のように機能します。

また、既存の会話がない場合も会話を開始します。

お役に立てば幸いです!

3
DigiLord

例:

get services
get name of services
get buddies
get name of buddies 

あなたの行:

send "Test-Message" to buddy "buddy" of service "service"

「バディ」と「サービス」が有効な場合に機能するようです。

Apple-IDが登録されたiMessageがあるので、「サービスの名前を取得」を実行すると、このサービスに対して次のような文字列が取得されます。

「E:[email protected]

「サービス」に使用できます。バディは、純粋なテキストとしてのあなたのバディの単なる名前です。 「仲間の名前を取得する」を参照してください。

うまくいきますように!

3
osxgeek

OK、ログインしたユーザーのフルネームを取得し、連絡先から一致するiPhone番号、サービス名を見つけ、最後に(前のアクションからの)着信テキストを送信するAutomatorアクションに次のようにしました。 iMessage上の.myself。少なくとも現時点ではあまり有用ではありませんが、ある意味でそれが可能であることを証明しました:)

set input to "Testing 123" **//This line is just for testing**
tell application "System Events"
    set MyName to get full name of current user
end tell
  tell application "Contacts"
      set myPhone to value of phone 1 of (person 1 whose name = MyName)   
      whose label = "iPhone"
   end tell
tell application "Messages"
    set MyService to get name of service of buddy MyName
    send input to buddy myPhone of service MyService
end tell
0
Andreas