Scripting text colour

Ni
Nick Sloan
Posts: 16
Joined: Mon Jan 07, 2008 10:36 am
Location: Somerset UK

Mon Jan 07, 2008 1:38 pm Post

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

User avatar
AmberV
Posts: 24331
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Mon Jan 07, 2008 5:05 pm Post

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.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

Ni
Nick Sloan
Posts: 16
Joined: Mon Jan 07, 2008 10:36 am
Location: Somerset UK

Mon Jan 07, 2008 5:28 pm Post

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.

User avatar
AmberV
Posts: 24331
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Mon Jan 07, 2008 6:33 pm Post

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.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

User avatar
KB
Site Admin
Posts: 20834
Joined: Tue Jun 13, 2006 11:23 pm
Platform: Mac
Location: Truro, Cornwall
Contact:

Mon Jan 07, 2008 7:13 pm Post

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

Ni
Nick Sloan
Posts: 16
Joined: Mon Jan 07, 2008 10:36 am
Location: Somerset UK

Fri Jan 11, 2008 9:26 am Post

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.