The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Color & Applescript Thread Tools Search this Thread Display Modes
I'm not sure if this can be done because I know nothing about applescript. Basically what I want to do is be able to change the text color with a keyboard short cut key, and then turn it off by pressing (ideally the same) keyboard keys. In other words, I want to be able to change text color the same way I would a change text to bold.

All I know is that I could create a keyboardmaestro (its how I currently deal with annoying underline feature in OO) shortcut to activate a script but I don't know if applescript can change the color of text in OO.

Of course, I am not asking anyone to write a script. What I am asking if something like this is conceivably possible - I would love to be able to quickly color code certain notes, terms, etc.
 
I know you can change it for an entire cell. An example:

Code:
tell application "OmniOutliner"
	tell front document
		set color of text of topic cell of selected rows to {0, 0, 65535}
	end tell
end tell
This code changes the contents of the topic column for the selected rows to be bright blue. I don't know how you can grab just the portion of the cell that is selected, however. What does your underlining setup look like?
 
My underlining setup? Do you mean how I color code stuff? I use omnioutliner to outline court cases/statutes and I use certain colors to signify certain types of reasoning, etc. For example, if policy argument: blue text; if textual interpretation: orange text, etc.

Right now I just apply the colors manually, which doesn't take that long but it would be great to shave some time off of the process and be less of a disruption. I tried to just make a macro using KM and record the mouse clicks but that doesn't work well because it depends on where the program is on the screen, etc.

I could just limit a certain type of reasoning to one cell (sometimes when I copying a quote, there is multiple types of reasoning in one sentence) and then use the script you provided (and use a keyboard shortcut using KM). I was thinking maybe they was an applescript that said "turn current selection to color x".
 
Quote:
Originally Posted by kparsons View Post
My underlining setup? Do you mean how I color code stuff?
No, I meant your underlining stuff you said you use Keyboard Maestro to "deal with annoying underline feature in OO" and I'm curious how you are doing it (haven't used Keyboard Maestro before). It might be possible to adapt what is done there (I assume that you can underline just the selected text).

Quote:
I could just limit a certain type of reasoning to one cell (sometimes when I copying a quote, there is multiple types of reasoning in one sentence) and then use the script you provided (and use a keyboard shortcut using KM). I was thinking maybe they was an applescript that said "turn current selection to color x".
Not that I found, but I don't do much tinkering with text formatting in AppleScript. My pal RobTrew is probably laughing too hard at my answer to give you a better one :-)
 
Ha, sorry, what I have KM do is press control+U three times when I press control+y. KM is a macro utility (that is surprisingly powerful). I attached a screenshot which I think makes it pretty self-explanatory. I also use KM to create templates but all that is easy because it just uses keyboard input but there is no way, that I know of, to change color just using the keyboard.
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2011-12-15 at 10.01.44 PM.png
Views:	439
Size:	51.7 KB
ID:	2150  
 
From what I have read, and the little bit of it I understood, I would need a way for applescript to identify the selected text. I found this discussion of it on macscripter. Honestly, I don't understand applescript but I do have book on the way about - I've got it in my head that I am going to figure out a way to do this.
 
Do you have OmniOutliner or OmniOutliner Pro? Pro has a feature called Named styles that allows you to select some text and press a function key to instantly apply that style. You could have up to 8 of them (F1-F8), and the style could of course be as simple as just changing the text color. See the built-in help for "Named styles" for more details. Plain old OmniOutliner can view and edit named styles, but can't create new ones, and they don't appear to get the function key binding, so it wouldn't be so useful. If you're a student, the educational upgrade price to Pro is only $25, and if you're a practicing attorney I don't want to hear any complaining about the price or I'll need to collect a hefty retainer before answering any more questions from you :-)
 
whpalmer4 will correct me if I am missing something here, but I think the key problem is that the Applescript library doesn't offer us a reference to selected text (only to selected rows), so there doesn't seem to be anything very quick or elegant in sight.

Quote:
Originally Posted by kparsons View Post
I tried to just make a macro using KM and record the mouse clicks but that doesn't work well because it depends on where the program is on the screen
A workaround might be to get KM5 to open the color dialog, and then get Applescript to position and size the dialog (at top left of the screen) so that mouse click coordinates relative to the top left corner of the display can be used.

You could use a fragment of Applescript like:
Code:
tell application id "OOut"
	activate
	set strAppName to name
end tell

tell application id "sevs"
	tell window "Colors" of application process strAppName
		set position to {0, 22}
		set size to {300, 400}
	end tell
end tell
inside a KM5 macro like the one attached below, which specifies a color in terms of RGB values. Not fast, a bit klunky, but seems to work on my system :-)

--
Attached Files
File Type: zip SetColorRed.kmmacros.zip (2.4 KB, 256 views)

Last edited by RobTrew; 2011-12-16 at 03:34 AM..
 
PS

A faster approach might be to create a few KM macros which use a similar technique (positioning and sizing the color dialog at top left of the screen), to click on one of the user-defined colors at the bottom of the dialog.

(one way of reading off the screen coordinates is to use the Cmd-Shift-4 screen capture cursor).

(Sample macros for user colors 1-6 below)

--
Attached Files
File Type: zip SetColors.kmmacros.zip (2.3 KB, 250 views)

Last edited by RobTrew; 2011-12-16 at 03:22 AM.. Reason: Added point about Cmd-Shift-4
 
Thank you guys for your help. The named styles option actually works really well. What I will do is create a KM where when, for example, I press ctrl+shift+(x) it will trigger one of the function keys (because it is physically awkward to use function keys when typing).

Robtrew, I got your macros to work to on my system, but as you said its a clunky. Its too bad there isn't a uniform applescript library for all programs on a mac.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Color Value ashtonfedler OmniGraffle General 2 2012-05-18 12:18 AM
how to applescript changing a row's background color? wfiveash OmniOutliner 3 for Mac 4 2010-10-28 02:02 PM
how to set priority or color? rllewis@mac.com OmniFocus 1 for Mac 2 2008-08-22 02:28 PM
Task color doesn't match the group's color mr_projects OmniPlan General 1 2007-11-02 11:34 AM
Changing fill color in AppleScript action mduser63 OmniGraffle General 1 2006-06-27 09:23 PM


All times are GMT -8. The time now is 08:11 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.