Stuck on a macro to paste from screencapture to specific folder in notes.app

Hi all

@ccstone macro gave me a good starting point to try to create a macro that will paste from screencapture to specific folder in notes.app. I can capture the image, switch to the notes app and even create a specific note in a specific folder with text but cant understand how to paste the clipboard captured image into the note. Here is the current state of the macro

I assume its possible in the line that says

**make** new *note* at *folder* "temp.notes" with properties {name:"this is a test", body:"and more text"}

I can somehow paste the image like I do with the name:" part?

anyone have any experience with note/applescript to help out?

thx!

Z

I haven't really used the Apple Notes app (much prefer Evernote), but assuming that the above macro/script opens the Notes document, and the cursor is in the body of the Note, you could just add these KM Actions:

image

thx @JMichaelTX!

I thought at that initially but couldn’t find a keyboard/menu way top focus the folder pane in order to issue the keystroke down method. Also seemed like AppleScript would be more robust :slight_smile:

thx !
Z

AppleScript is very robust -- almost never fails/crashes. I suppose you meant "more powerful". If you want more power, use AppleScriptObjectiveC.

Give this script a try. It works for me.

tell application "Notes"
  activate
  set oNote to make new note at folder "temp.notes" with properties {name:"this is a test 6", body:"and more text with image below."}
  
  show oNote
  delay 0.5
  tell application "System Events"
    key code 125 using command down -- Go to bottom of Note
    key code 36  -- RETURN key (to go to next line)
    keystroke "v" using command down -- Paste
  end tell
  
end tell

I use Notes a lot, and I've automated its use with KM.

You said you "couldn’t find a keyboard/menu way top focus the folder pane in order to issue the keystroke down method". I found a way. Just close and re-open notes. It's always defaulting to the Folders pane when I do that, resulting in Down Arrow always working. Another way I found is to click in the folder pane, which for me means clicking on the iCloud word at the top of the pane. Do those methods not work for you? If not, we may be able to find other methods. I found another way that uses only keystrokes if you insist on such a method. What you probably want is a menu item that guarantees a correct context switch, but I didn't find one of those.

You may want to consider using Evernote.

It is much easier to use than Notes, much more powerful, great search, has tags, syncs on ALL of your devices (Mac, iOS, Windows, Android).

But the big bonus is Evernote is very AppleScriptable!
I have highly automated, and extended, Evernote using AppleScript.

EDIT: Almost forgot. There is a script to copy your Apple Notes to Evernote.

Thank you all for your invaluable comments, I truly appreciate it

I ended up going the @JMichaelTX route with the apple script. It seems to work really well!

one last thing if you guys don't mind. Is it possible to add the current date or another running number in the:

with properties {name:"", body:""}

section so that the notes are differentiated? So something like

with properties {name:"%LocalDate%", body:""}

I tried that but the syntax of keyboard maestro obviously docent work in AppleScript (that much I know even though I cant code to save my life..:))

p.s this is the current state of macro in case anyone is interested:

You had me at "scriptable". So I went to the app store. There were several things that bothered me:

  • Many reviews on the App store site said that it "crashed a lot";
  • They have a "full version" that costs C$100/year and they don't explain what their "entry version" is missing;
  • They insist on taking my email address for the entry version;
  • They don't tell me what country my notes are stored in on their cloud storage or whether my notes are encrypted in transit;
  • They asked me for permission to place cookies on my computer but even before I clicked "OK" they had already put a cookie on my computer. That's disrespectful. I even declined to accept their cookie policy but the cookie stayed on my computer. So why do they even bother asking if they ignore my answer?

They are definitely doing all the wrong things if they want my business.

Yes, very easy.

Insert whichever date format you want at the top of the script:

set dateStr to date string of (current date)
-->Friday, September 13, 2019

set dateISOStr to text 1 thru 10 of ((current date) as «class isot» as string)
-->2019-09-13

then just use the appropriate AS Variable for the "name" or "body" field:

set oNote to make new note at folder "temp.notes" with properties {name:dateISOStr, body:""}