Monday, May 25, 2020

#1 2020-05-18 09:13:16 pm

daBee
Member
Registered: 2010-02-09
Posts: 118

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


Filed under: messages

Offline

 

#2 2020-05-19 11:00:42 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1258

Re: Paste Into Current Messages Window

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

Applescript:


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

Last edited by KniazidisR (2020-05-19 11:03:15 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#3 2020-05-19 11:40:47 pm

daBee
Member
Registered: 2010-02-09
Posts: 118

Re: Paste Into Current Messages Window

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

Applescript:

...
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!

Offline

 

#4 2020-05-19 11:59:34 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1258

Re: Paste Into Current Messages Window

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)

Last edited by KniazidisR (2020-05-20 12:00:43 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#5 2020-05-20 12:00:33 am

daBee
Member
Registered: 2010-02-09
Posts: 118

Re: Paste Into Current Messages Window

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

Cheers

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)