Scripting text colour

In Nisus I have a series of scripts to change the colour of selected text. The text of the red script runs as follows (and works fine):

tell application “Nisus Writer Pro”
set color of selected text of document 1 to {56540, 0, 0}
end tell

When I try to adapt this script to Scrivener, Script Editor doesn’t like the phrase “selected text” .(It does not appear to exist as a Nisus scripting definition either, though it is understood in practice.)

If I remove “selected”, the script recompiles with “rich text”, but when I run it on selected (or unselected) text from within Scrivener it does not appear to do anything.

I should be extremely grateful to anyone who could suggest what I need to do in order to change text colour via AppleScript.
Thanks, Nick

At the moment (and likely for some time to come), Scrivener has no AppleScript support, which is why nothing is happening for you. Oh, and I think the “selected text of” syntax is built in to the default Apple dictionaries for text editing, and not part of any application specific dictionaries.

Well that would cerftainly explain it! Thanks Amber.
But then why does dragging Scrivener onto Script Editor produce a scripting definitions window? Admittedly only Standard and Text suites, but I always assumed that this was a good way of discovering whether an app is scriptable or not.

Hmm, good point! I haven’t tried doing that in ages, because the last time I tried it didn’t have a dictionary. I can even do a tell quit. It looks like some of the stuff is there. Well, I wonder if perhaps it has something to do with how many text editing views can be open at once? Notes, Split A, Split B, Synopsis. I’ve never done any scripting in an application with multiple text views before, and am not sure how to address them.

Hi, the reason for that is that I started looking into AppleScript support and did a few basic things to support it (such as declaring in the info file that it can access certain basic scripting features). However, I then realised that it would be a lot of work to open up even the basic features of Scrivener and would take longer than I had time to give it, so had to put it off for the future. AppleScript is still on the cards, but probably not until much later in the year - sorry!
All the best,
Keith

Thanks for the explanation Keith, and nice to hear that scripting is still on the cards.
At least this topic will serve as another answer to the question you posted elsewhere about what users might want to use scripting for.