JMColett Posted January 10, 2015 Share Posted January 10, 2015 Recently started using some new applications and the triggers I'd set up in Quicksilver are no longer working with those applications (BusyCal 2.6.3, for example). My understanding is that Quicksilver has become somewhat out-of-date, so I'm trying Afred so see if it will work better. I'm looking for a way to paste specific color data over text (in TextEdit, Yojimbo, or OmniGraffle, for example). In Quicksilver, I used the shelf to store the color data, then set up triggers with a different hotkey for each specific color: red, green, blue, etc. (Red was "Shift-Option-Command-R", for example, and blue was "Control-B".) The shelf was a key step, because I couldn't figure out any other way to isolate the color data and put it into the command field. I'm a teacher, and being able to paste colors over highlighted text quickly helps me when editing and giving feedback on others' writing (essays and articles, for example) or when composing my own lesson plans. (Red means "cut this text", blue means "rethink this part", green means "I went ahead and fixed this for you"). My question is: how do you set up a hotkey that will change the color of highlighted text to a specific color? Link to comment
RodgerWW Posted January 11, 2015 Share Posted January 11, 2015 For TextEdit it's fairly easy: 1: Create a new blank workflow 2: Add three hotkey triggers, one for each color you want 3: Add three RunNSApplescript Actions, again, one for each color. Now, in each of the RunNSApplescript Action boxes, you will want to paste this: on alfred_script(q) tell application "System Events" to tell text area 1 of scroll area 1 of window 1 of process "TextEdit" to if exists then set {x, y} to value of attribute "AXSelectedTextRange" if x ≤ y then tell application "TextEdit" to set color of document 1's characters x thru y to {65535, 0, 0} end if end alfred_script NOTE: That I also copied the included 'alfred_script', so if you just copy and paste the above into the window, make sure you overwrite the others already in there. ALSO NOTE: The color in brackets for the above is RED as the format is {RED, GREEN, BLUE} and the initial value is all red, and zero green and blue. For the green NSAppleScript {0, 65535, 0}, For the blue NSAppleScript {0, 0, 65535} Then, connect your hotkey boxes to the appropriate NSAppleScript Boxes. rice.shawn 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now