Mike Meyer
Mike Meyer

Reputation: 515

Getting message info from Messages.app with AppleScript

I’m looking to get information about individual messages in chat threads in Messages.app.

I can get individual chat threads:

set firstChat to first chat

I can get everything I ever wanted to know about file transfers (media sent/received via iMessage):

get properties of the last file transfer whose direction is incoming

I can handle messages as they arrive (which is pretty magical):

on message received msg from bud
    processIncomingMessage(msg, bud)
end message received

I just can’t figure out how to get information about individual messages. I’ve pored over the dictionary for Messages.app. It’s been super helpful up until I reach chat, then it seems I can’t get more specific than a chat thread.

The incoming message handler is great, but it doesn’t give me anything interesting in the message parameter. I can’t even get an index of the message.

Have I missed something, or is it not possible to get information about individual messages?


I have officially declared “f**k it” and given up on finding an AppleScript-y way of getting messages. Everything I need is encased in glorious SQLite (~/Library/Messages/chat.db). Thank you all for your help, I couldn’t have done it without you, keep up the good work, etc. etc.

Upvotes: 3

Views: 2563

Answers (1)

double_j
double_j

Reputation: 1716

tell application "Messages" to set lastmessage to subject of first text chat

Upvotes: -1

Related Questions