Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

ios - iMessage Apple script - Trying to send a message to target that can be the Full Name or Number

I am trying to take in a target and have an if statement determine if it's a phone number or the full name. I cant seem to figure out how to find the full name from the iMessage app. Here is what I got so far and it seems to just be when the target is a noninteger.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

    launch application "Messages"
    tell application "Messages"
        set targetService to 1st account whose service type = iMessage
        set targetPhoneNumber to "Alejandro Cervantes"
        set targetMessageToSend to "Test"
        
        if targetPhoneNumber is not integer then
            set targetName to get id of account of participant targetPhoneNumber
            set targetBuddy to participant targetPhoneNumber of targetService whose full name is targetPhoneNumber
        else
            set targetBuddy to participant targetPhoneNumber of targetService
        end if
        
        set targetMessage to targetMessageToSend
        send targetMessage to targetBuddy
        
    end tell
question from:https://stackoverflow.com/questions/65909296/imessage-apple-script-trying-to-send-a-message-to-target-that-can-be-the-full

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...