How to start new conversation in iMessage using AppleScript?

后端 未结 2 1716
礼貌的吻别
礼貌的吻别 2020-12-16 14:02

So I\'m working on creating an applescript which essentially automates sending an imessage. What I have working now is:

on run {msg, phoneNum}
    tell appl         


        
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 14:10

    There are many ways to do it.

    First example:

    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
    

    Second example:

    tell application "Messages"
        set targetBuddy to "+18001234567"
        set targetService to id of 1st service whose service type = iMessage
        repeat
            set textMessage to "Hello pal!"
            set theBuddy to buddy targetBuddy of service id targetService
            send textMessage to theBuddy
            delay (random number from 10 to 30)
        end repeat
    end tell
    

提交回复
热议问题