2012-08-04 18 views
11

メッセージアプリを使用してiMessageのユーザーにメッセージを直接送信する方法を教えてもらえますか?提供されたサービスでのみ、AppleScriptで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経由でアカウントにメッセージを送信する必要があります。 ありがとうございました!

答えて

32

代わりにハードコードするIMessageがサービスを有していると、あなたは自動的にそれを見つけることができます。

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

sendMessage。アップルスクリプト:

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 
+3

注:iMessage **あなたは**できません! – fabian789

+0

@ fabian789ヒントをありがとう。この制限を回避する方法を知っていますか? iMessageを自分で(Messages.appから手動で)送信できるので、スクリプトでこれを行う方法はありませんか? – Chris

+1

@Chrisいいえ、私はそれが可能だとは思わない – fabian789

2

例:

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

あなたのライン:

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

は "バディ" と "サービス" は有効である場合に動作するようです。

私はアップルID登録と私のIMessageがを持っているので、私は、私は、このサービスのために

私は「サービス」のために使用することができます

"E:[email protected]"

のような文字列を取得「サービスの名前を取得する」を実行したとき。バディはあなたのバディの名前にすぎず、純粋なテキストでもあります。 「バディの名前を取得する」を参照してください。

うまくいきますように!

7

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 
+1

に可能であることが証明され、これに従ってください - http://stackoverflow.com/questions/39027839/how-to-start-new-conversation-in-imessage-using-applescript。 – mac

+0

@macこれはこれ以上働いていません.. – andi

3
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設定のアカウントに入り、iMessageアカウントを最初に並べ替える必要があります。その後、これは魅力のように機能します。

これも存在しない場合、会話を開始します。

希望に役立ちます!

6

このスクリプトは、メッセージごとに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 
+0

https://stackoverflow.com/questions/39027839/how-to-start-new-conversation-in-imessage-using-applescriptでご覧になれますか? – andi

0

[OK]をお送りします、私はちょうどuser'sフルネームでログインして掴むのAutomatorアクションに次のように作られました、連絡先、サービス名から一致するiPhone番号を見つけ、最後に(前の動作からの)着信テキストをiMessageの...自分宛に送信します。現時点では、少なくとも私には、非常に有用ではありませんが、私はそれが新しい会話を開始する方法:)

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 
関連する問題