Hot Key to Open a Specific Apple Note?

I'm trying to work out if KBM can do this via a macro, or whether I'd have to go into apple script (yet another learning curve) LOL.

Typically I'd like to assign a hot key (say cmd S) which would work with Apple Notes to:

  • Activate the Notes app if it is closed
  • Open a specific note with the heading of '~Scratchpad~'
  • If the '~Scratchpad~' note was opened then send it to the background.
    Basically it'd operate to flip / flop the visibility of that singe note on the desktop.

This is with KBM v9.1 and Big Sur 11.0.1.

Hopefully this should be my last question for a while. :slight_smile:

I've gotten as far as opening the Notes app and placing it on the right note with:

tell application "Notes"
   show note "~Scratchpad~"
end tell

And using Select Menu in Front Application then Menu Title 'Window' Menu Item 'Float Selected Note'
More progress Apple script added to size / position the note:

tell application "Notes" to set the bounds of the front window to {2900, 80, 3300, 800}

So the bits left to work out are:

  1. Close the main notes app itself leaving the desired note open
  2. Close the note if it is already open when the hotkey is hit.

I'll carry on playing...  :slight_smile:


DMB Execute Notes, Scratchpad 3.kmmacros (3.9 KB)
I've now got as the macro working after a lot of DuckDuckGo'ing and playing around. I've a feeling though that this is not that elegant and likely not the best way of doing things. It still only achieves the opening of the single note.

A question on the macro. How on earth do you enter a comment box at the top of the macro? I can't see that option in the Editor?
Also looking to work out how to abort the macro if the note is already open. (I've given up on sending the note to the background) :slight_smile:

There's also Hook app, has been mentioned here in the forum

Thanks I'll take a look at it.

1 Like

Hey Daron,

A working macro is leagues better than a non-existent or non-working elegant macro.  :wink:

But – for the exercise – let's try for more efficient anyway.

The AppleScript below does everything your macro does in one fell swoop.

I'll let you decide if it's elegant or not.  :sunglasses:

-Chris


--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2020/12/04 13:07
# dMod: 2020/12/04 13:07 
# Appl: Notes, System Events
# Task: Open and Float a Specific Note
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Notes, @System_Events, @Open, @Float
# Reqs: Requires Mojave or later.
# Vers: 1.00
--------------------------------------------------------

property noteName : "Blood Pressure Log"

--------------------------------------------------------

tell application "Notes"
   
   set theNote to first note whose name is noteName
   show theNote
   
   my floatNote()
   
   close (windows whose name is not noteName)
   
   set bounds of window noteName to {720, 23, 1440, 900}
   
end tell

--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
on floatNote()
   tell application "System Events"
      tell application process "Notes"
         tell menu bar 1
            tell menu bar item "Window"
               tell menu 1
                  tell menu item "Float Selected Note"
                     perform action "AXPress"
                  end tell
               end tell
            end tell
         end tell
      end tell
   end tell
end floatNote
--------------------------------------------------------
2 Likes

Thanks Chris, that is a lot neater :slight_smile: Many thanks!

1 Like

Hey Jarrod,

Welcome to the forum!   :smile:

No!  :sunglasses:

At least not until you show us the AppleScript you're running and tell us which version of macOS you're running it on.

-Chris

1 Like

:joy:
made me laugh

@Jarrod_Job as cc says, it'd be faster to fix if we can see the code

1 Like

Although the 'linking to note' is already handled, I'll add a great tip I just picked up for future readers doing similar things. You can generate a unique URL for a note by sharing it. You don't have to actually send the sharing link to anyone, but you can then open it anywhere that takes a URL.

I use it to create links between notes - which makes notes.app way more powerful for me. (You can right-click on any link in notes to change its displayed name & hide the long URL.)

(as an aside, does anyone know a quicker way to get a sharing URL? the sharing dialog makes you send it somewhere, so i just send to myself)

here's a macro to open a note I just made, via its sharing URL.

Open Avi's note.kmmacros (1.2 KB)

edit: If you make your own macros to open individual notes, make your Open URL macro action use "Default Application", not the Notes app.

anyone know a quicker way to get a sharing URL

Are you using KM to automate part of the process?

I think your question might be good for a new topic

@ccstone thanks friends. I was able to find a simpler method to what I needed. But it went through this post to find it, so I am super grateful.

I will delete my post from above. <3

-Jarrod

1 Like

What did you figure out?

Others might like to know.

-Chris

I wasn’t accurate there. I put together a script that simply allows me to hot key into a specific note. Unsure if that would be helpful or not. If so, I’ll add to the thread.

F08 = Note A
F09 = Note B
Etc.

What are you doing?

Just AppleScript and:

show theNoteRef

Or something else?

-Chris

Correct.
Tell application “Notes”
Show note “theNoteRef
End tell

1 Like

Those interested in this topic, might also find the following post useful: Float Selected Apple Note - Macro Library - Keyboard Maestro Discourse. It includes a Notes App AppleScript.

2 Likes

Here is what I use. The move and clicks use the "float this note in separate window" functionality. Works Great. You can download the macro below, and put in your own Note name. Also note for some reason I could note get the Float Window to function using a shortcut key and resorted to using move and click. Depending on your resolution, this may need tweaking on your side. Good luck! let me know if you can improve this.

Open a specific Note.kmmacros (8.7 KB)

1 Like

Thanks Avi. I'm really interested in this idea, but I can't get it to. work. My Notes don't share via email, that option is not in the list, and the options that are available just sent the text content of the note, not link to the dynamic note content.

Was there some other setup that you did to make this work? Which OS version? I'm on Mojave and I suspect that's the issue.

AH HA! It's not the Share menu. (Here's from the Notes Help:)
image

It's the Add People option.
image
I can click that button and, instead of sending email, there's an option to "Copy Link". I click that and I can paste the link directly into another note.

Thanks.

Thanks for sharing that. I'd like to try it. Could you please upload the macro for downloading? (Ask if you need help with that.)

P.S. Welcome to the KM Forum!