-1

I've tried pyimessage, applescript, and osascript. The only thing I could find that seemed promising was this older stackoverflow question:

Send group iMessage using applescript

I wasn't able to get that working. Has anyone been able to send to an existing group chat?

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 01 '21 at 04:46
  • First you need to figure out how to send chat messages using AppleScript in Script Editor. Once you’ve got that part working correctly, you can figure out how to run that AppleScript from osascript/py-applescript as a separate step. If you get stuck on either of these steps, post your code plus any error information you have so folks here can see where you’re at. – foo Nov 01 '21 at 08:20

1 Answers1

0

I can send individual messages on applescript. I can also send to the same message to multiple people. What I can't do is send to a group chat. I've got a group name containing two people named in my icloud and in my contacts and in a current chat. Here's the code I do that with:

import PySimpleGUI as sg
import sys
import subprocess
from os import system, name
from playsound import playsound

people = "Firstname Lastname", "Firstname Lastname"
msg = 'test'


def onCall():
    
    applescript = (
    """
set people to "{0}"


tell application "Messages"
    repeat with myBuddy in buddies
        --get properties of myBuddy
        if name of myBuddy is in people then
            send "{1}" to myBuddy
        end if
    end repeat
end tell
""".format(people, msg
           )
    )
    
    args = [
        item
        for x in [("-e", l.strip()) for l in applescript.split("\n") if l.strip() != ""]
        for item in x
    ]
    proc = subprocess.Popen(["osascript"] + args, stdout=subprocess.PIPE)
    progname = proc.stdout.read().strip()


I call the function with a clickable button that does send messages when the Firstname and Lastname are known contacts. I don't get an error message. The text just doesn't send when I try to change any of the values to 'TestGroup' (which is what I have my group chat named'.