Save Selected Text To OS X Notes App From Right-Click Context Menu

Browser extensions and add-ons that allow you to save selected text as notes are one of the easiest ways to save useful text snippets for easily retrieving them later. However, these notes are mostly confined to your browser. Outside the browser, there are apps that can run in the background and collect text from your clipboard. In OS X, you will notice that there is a system wide-option to select and search for text in Safari from any app. With the help of Automator, you can create a similar service that can be used to select text in any app and create a note in the default Notes app with it.

The process is very simple and doesn’t require any customization on your part. Start by opening Automator and creating a Service. By default, you will see two drop-down menus at the top. Make sure they are set to accept incoming text from any application, as shown in the screenshot below.

text input Save Selected Text To OS X Notes App From Right Click Context MenuView in gallery

From the utilities library (the list of utilities in the column on the left of the workflow area), drag & drop the the ‘Copy to Clipboard’ utility on to the workflow area. Next, drop the ‘Run AppleScript’ utility on to the workflow area and paste the following script where it says ‘(* Your Script goes here *)’, making sure you remove the parenthesis as well.

tell application "Notes" to activate

tell application "System Events"

 click menu item "Notes" of ((process "Notes")'s (menu bar 1)'s ¬

  (menu bar item "Window")'s (menu "Window"))

 click menu item "New Note" of ((process "Notes")'s (menu bar 1)'s ¬

  (menu bar item "File")'s (menu "File"))

    keystroke "v" using {command down}

end tell

When you run the service, it won’t be able to copy anything from the clipboard. Run it anyway; you shouldn’t see any other problems besides the clipboard error. Save the service and close it.

automator service Save Selected Text To OS X Notes App From Right Click Context MenuView in gallery

Now launch the Notes app and go to your browser or a word processor app, or just open a PDF in Preview – any app that lets you select text will do. Select some text, right click it and go to the Services submenu, where you will now find the service you just created. Click it, and the text will be added as a new note to Notes.

save-text-to-note.jpgView in gallery

Notes will use the text of the newly created note to name the note. What it also does is overwrite your clipboard with the same text that you sent to the Notes app. If you would like to keep the clipboard out of this whole process, you can use the following script instead.

set theInput to quoted form of (input as text)

set noteText to do shell script "echo " & theInput & " | /usr/bin/textutil -stdin -stdout -convert html"

tell application "Notes"

tell account id (do shell script "defaults read -app Notes DefaultAccount")

        if not (exists folder "Notes") then make new folder with properties {name:"Notes"}

        tell folder "Notes"

            make new note with properties {body:noteText}

        end tell

    end tell

end tell

Follow the same process as above with only one difference – do NOT add the ‘Copy to Clipboard’ utility to the workflow. This method has one shortcoming though: it will not give the new note a proper title, and all notes created this way will be labelled ‘New Note’.

[via Mac OS X Hints]

  • Didn`t work here 🙁

  • Greg Zielinski

    If you prefer TextEdit:

    on run {input, parameters}

    tell application “TextEdit” to activate

    tell application “System Events”

    click menu item “New” of ((process “TextEdit”)’s (menu bar 1)’s ¬

    (menu bar item “File”)’s (menu “File”))

    keystroke “v” using {command down}

    end tell

    return input

    end run

  • Greg Zielinski

    you need to paste the code, remove empty lines as it won’t compile (probably some hidden characters), then compile it by pressing the hammer icon.. then run .. then save