Paste Into Current Messages Window

Hi folks.

I have generated some text that I want to share with a buddy over Messages. His chat is up, and instead of copying and pasting, I want to paste automatically via AS.

Is there a way to just say “activate messages and paste my clipboard into the bottom field”? I don’t want to send it, just populate the little bottom text generation field.

Cheers

See my simple script here. It works at least on the Mojave and the Catalina:


tell application "Messages" to activate
tell application "System Events" to tell application process "Messages"
	click menu item "New Message" of menu 1 of menu bar item "File" of menu bar 1
	click text field "To:" of scroll area 3 of splitter group 1 of window "Messages"
	keystroke "1234 123 123" & return -- buddy's phone
	click text area 1 of scroll area 4 of splitter group 1 of window "Messages"
	keystroke "Hi, have new message!" -- the text
end tell
delay 10 -- this is only to see the result

OK but that inserts a keystroke. I’m looking to paste the clipboard contents. This is what I found to work:

...
click text area 1 of scroll area 4 of splitter group 1 of window "Messages"
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
...

Very good. Cheers!

Well, I’m glad I could help you. I just want to note that I took this piece of script from another my script. Look here : Send multiple images. So, you can fill not only text messages, but files too (for example, photos)

Ya I’m a developer so I want to copy code over to messages quite often. Thought I could script it.

Cheers