Question: When using **Notes** I often find myself changing the color of the text (usually to blue or red) as an additional way to indicate emphasis (alongside *italics* and **bold**). 

The shortcut for displaying the available colors is **Command-Shift-C** but that still requires the user to use the mouse to click on a particular color. 

Does anyone know how I can add a single shortcut that will switch to a given color and then, when pressed again, switch back to black? (So it, in effect, works the same way the *italics* and **bold** shortcuts work).

I don't need to make a shortcut for *every* color--one for blue would do just fine. Any ideas?

Answer: 
Here's how to change text colour in Notes.app with a single hotkey:

Setup:
------

Use this AppleScript code which performs the whole thing (this example is for red text):

```
set noteBody to "<body><p style=\"color:#FF0000;\" >styletext</p></body>"

tell application "Notes"
    activate
    tell default account to tell folder "Notes"
        make new note with properties {body:noteBody}
    end tell
end tell

tell application "Notes"
    tell account "iCloud"
        tell folder "Notes"
            show note 1
        end tell
    end tell
end tell

delay 0.2

tell application "System Events"

    key code 48 #Tab into the temporary note so we can 'Copy Style' from it

end tell

tell application "System Events" to tell process "Notes"

    set frontmost to true
    click menu item "Copy Style" of menu 1 of menu item "Font" of menu 1 of menu bar item "Format" of menu bar 1

end tell

tell application "Notes"
    tell account "iCloud"
        tell folder "Notes"
            delete note 1
        end tell
    end tell
end tell

tell application "System Events"

    key code 50 using {command down} #Switch window back to working note with selected text

    delay 0.2

end tell

tell application "System Events" to tell process "Notes"

    set frontmost to true
    click menu item "Paste Style" of menu 1 of menu item "Font" of menu 1 of menu bar item "Format" of menu bar 1

end tell

```

Then assign the AppleScript a hotkey such as with [FastScripts](https://red-sweater.com/fastscripts/).

The method:
-----------

1. Open your working note in a standalone window by double-clicking on it.
2. Select the text you want to give a colour.
3. Press your FastScripts hotkey, and the colour is quickly applied.

Limitations:
------------

Non-boldness of your hotkey style to paste will apply to bold text, so you'll need to not mix formatting together but set specific hotkeys for every combination of colour + formatting that you use.

Bonuses:
--------

You can make as many colour hotkey as you want. In fact, due to the custom HTML in the AppleScript code, you could set any compatible colour + formatting combination, such as italics, bold, font size, highlight or text background, who knows what else.

E.g. for red bold it would be:

```
set noteBody to "<body><p style=\"color:#FF0000;\" >redtext</p></body>"

```

Helpful tips:
-------------

* This relies on you not customising Notes' menu item shortcuts from their defaults.
* This relies on you only having one main Notes window open and then another for the note you're working in.
* May have to customise other things in AppleScript according to how you use Notes, e.g. your chosen default account.

If anyone has improvements to this code or method, please contribute and I'll test it myself.
In TextEdit you can do something like:

```
tell application "System Events" to tell window 1 of process "TextEdit"
    set {x, y} to value of attribute "AXSelectedTextRange" of text area 1 of scroll area 1
end tell
tell application "TextEdit"
    set color of characters x thru y of document 1 to {65535, 0, 0}
end tell

```

I couldn't figure any way to do that in Notes though.