I'm using Circus Ponies NoteBook which doesn't support Applescript methods. It does support creating services that can clip the current selection into a NoteBook page. This allows me to select text and use the context menu to paste the text into a NoteBook page. I'd like to do the exact same thing from an Applescript script. Is there some way in Applescript to get a handle to an existing service, and send it a message?
3 Answers
Automator services can be run with the automator
command line utility:
do shell script "automator ~/Library/Services/test.workflow -i input -d variable=value"
I couldn't get it to work with the service used by Circus Ponies NoteBook though.
If you assign the service a keyboard shortcut through System Preferences » Keyboard » Keyboard Shortcuts » Services,
you can then use the AppleScript keystroke command to invoke that shortcut.
I made such an Automator action to invoke a Service.
See
https://blog.tempel.org/2015/09/RunServiceForAutomator.html
and
https://github.com/tempelmann/RunServiceActionForAutomator
All that's left is figuring out is how to invoke an Automator workflow from AppleScript. Lri's answer might help with that.