Script to apply style within RTF *and* Label the RTF

I use rich-text files to take notes in meetings, and apply a style (red color) to text that contains to-dos. Then I label the file (‘To do’), so I can return to it later and easily find the to-dos I assigned myself.

:neutral_face: Here’s my workflow:
1 / I highlight the text, open the Styles drop-down menu, and select the style (red text).
2 / Then I select the document, and apply a label using a keyboard shortcut.

:wink: What I’d like is:
I highlight the text, and then run a script that applies the style and labels the document.

Is that possible? Are there any precedents? :confused:

Does it have to be a script? I do something similar, but I just use the standard OS shortcut system.

E.g. Once you’ve got your style the way you want it (let’s call it ‘Red’), then use system preferences to assign a shortcut to it. You can do the same thing with the label.

So my workflow is, say, select text, ctl-cmd-R, ctl-cmd-3, which is only one fewer shortcuts than a script and easier to set up.

I agree with brookter’s method. It would be much more painful to try to write a script for this.

A script that toggles the label is simple, and can be assigned a short cut

20140822.  Toggle my label. labels are numbered from 0 [no label] to 7, with 1 through 7 being the colors
set in DEVONthink preferences.  Set the labelSet property to value from 1 through 7.

property labelSet : 1

tell application id "DNtp"
	if the label of the content record is labelSet then
		set the label of the content record to 0
		set the label of the content record to labelSet
	end if
end tell

Yeah - the highlighting, not so much. :smiley:

Thanks, all! I agree, let’s keep it simple and forget the scripts.

But here’s where I have trouble:

I don’t think you can assign shortcuts to styles. At least, when I try it doesn’t work. :neutral_face:

Here’s a screenshot of the pull-down Styles menu, where my style is “@ Red text > To-do”.

Style can be given shortcuts in System Preferences > Keyboard > Shortcuts > App Shortcuts. Add your shortcut to the “All Applications” section, such as:

Okay! That makes sense; I was trying to do it just in the Devonthink shortcuts.

Thanks so much.