[Superseded 2022-01-04] MACRO: Float Selected Apple Note v1.0


AUTHOR'S NOTE – 2022-01-04 – THIS MACRO WAS SUPERSEDED


I've contributed a similar macro that is considerably more flexible. Refer to:

MACRO: Float Specified Apple Notes - Macro Library - Keyboard Maestro Discourse


PURPOSE
This macro will open the Apple Notes app and float a selected note. Thus it provides a convenient method to access frequently used notes.

SETTINGS
local_Favorite_Folders_Titles : This multiple-line variable is in the format (for each line):

Notes App Folder:::Note Title Substring

Three consecutive colons (:::) should be used to delimit the Notes App Folders and Note Title Substrings (both case-insensitive).

The Notes App Folder (and delimiter) can be excluded on the lines, however, the search will be faster if a note is within a folder and a folder is specified.

The macro will generate a Prompt With List that includes all of the specified Note Title Substrings. The selected note will then be floated.

If local_Favorite_Folders_Titles includes only one line, the Prompt With List will be skipped and the specified note will be immediately floated.

ACKNOWLEDGEMENTS
This macro includes an AppleScript which was derived from a template created by @JMichaelTX and shared: What is Best Practice for Handling Script Errors in Execute Script Action?

TESTED WITH
• Monterey, v12.0.1
• Keyboard Maestro, v10.0.2
• MacBookPro16,1

VERSION HISTORY
1.0 - Initial version

DOWNLOAD Macro File:
Float Selected Apple Note.kmmacros (44 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Image • Float Selected Apple Note

4 Likes

I'm still new to Keyboard Maestro and I can't seem to find the best way to make it open multiple notes at one time. What do I have to modify?

This seems like an overly complicated way of doing it now that I spend 5 minutes finding an AppleScript.

tell application "Notes"

show note "Note name here"

activate

end tell

delay 0.5

tell application "System Events" to ¬

tell application process "Notes" to ¬

click menu item "Float on Top" of ¬ (Don't copy this -> Depending on your use replace "Float on Top" with "Float Selected Note")

menu 1 of ¬

menu bar item "Window" of ¬

menu bar 1

@Undertaker01, the macro has two modes. The mode depends on the number of items (each being a Note Title substring) that are entered into the variable local_Favorite_Folders_Titles. If more than one item is entered, each must be on a separate line.

  • Two or more items: A Prompt With List is generated. After the user selects one of the items, the corresponding note is floated (opened in a dedicated window) .
  • One item: The corresponding note is immediately floated with no user interaction required.

Here are three local_Favorite_Folders_Titles examples:

Example 1 (One item, folder specified)

tmp:::scratch note

If the tmp folder contains a note that includes scratch note in the Title, that note will be immediately floated.


Example 2 (One item, no folder specified)

scratch note

If the any folder contains a note that includes scratch note in the Title, that note will be immediately floated.


Example 3 (Two items, one with folder specified)

a portion of some other note title
tmp:::scratch note

A Prompt With List is generated that contains:

a portion of some other note title
scratch note

(Note that folder names are intentionally excluded from the Prompt With List.) After the user selects one of the items from the Prompt With List, the corresponding note is floated.


@Undertaker01, back to your original question...

if you want to open multiple notes at one time with a single trigger (e.g., Hot Key), you could duplicate this macro and use each like Example 1 or 2. In each copy you would need to specify the note of interest in the variable local_Favorite_Folders_Titles. Finally you would create a new macro that would execute each of the replicates. (See action:Execute a Macro.) Here's a simple example:

Float Multiple Notes

Admittedly this is a brute force method, but sometimes brute force yields the quickest solution.

My end goal in this macro is to open the notes windows & position them on my screen. This is what I have so far.

tell application "Notes"
   show note "MyNoteName"
   activate
end tell

tell application "System Events"
   tell application process "Notes"
      
      click menu item "Float Selected Note" of ¬
         menu 1 of ¬
         menu bar item "Window" of ¬
         menu bar 1
      
      click menu item "MyNoteName" of ¬
         menu 1 of ¬
         menu bar item "Window" of ¬
         menu bar 1
      
   end tell
end tell

The reason I have it click the note is I want it to float on top and with the "show" script it doesn't focus the note I opened in a window making the command not work -> I'm not knowledgeable with applescript yet so I did what seemed best to me.

I am going to have it open 3 or so notes

@Undertaker01, since you new with Keyboard Maestro (and thereby I'm assuming new with the forum), please allow me to explain how the Macro Library section works...

Users share macros that they feel might be useful to others. Ideally these macros will include a comment that describes the use of the macro. Then other users in the forum:

  • use the macro as-is,
  • suggest an enhancement, and/or
  • get ideas from the macro and create their own.

When one is developing a new macro and has questions for the community, these inquires should be entered into the Questions & Suggestions section of the forum.

I hope that helps. For more information, please refer to Getting Started with Keyboard Maestro and the Forum. There's a wealth information that will help you get started, which is a good thing because the Keyboard Maestro learning curve is somewhat steep—but well worth the climb.

Finally, you'll find that the participants in this forum are friendly and helpful, but information can be shared and problems solved more quickly if the guidelines are understood and followed.

1 Like

After using your macro for a few days I love it. I made a slight adjustment to it and added a switch action at the beginning that reads the %TriggerValue% token and sets the local_Favorite_Folders_Titles variable accordingly.

This allows me to call this macro using the Execute a macro action, pass a parameter to it and have it open a specific note according to that parameter. I’ve used it to replace several key steps of my more frequently used macros and it works like a charm!

Thanks for such a great macro!

-Chris

2 Likes

@cdthomer, you're welcome. Glad you find it useful.

This sounds like a nice enhancement. If you share an image of the macro changes (here or via PM), I'll update the macro so others can benefit. Thanks, Chris!

Glad to! Screenshot and the portion of the macro I modified.

-Chris

EDIT: Also adding how I call this from a different macro using a parameter to open a note.

Open specified Apple Note (orginal macro).kmmacros shows the only modification I made to the original macro. I used a switch action to do different things based on the %TriggerValue% token. If that token is empty (indicating I triggered this macro directly instead of from a calling macro), it works as originally intended with a list. If the token has a parameter (supplied in the Execute a macro action seen further down) then it sets the variable to open a note to a specific note so it opens it automatically.

Open specified Apple Note (orginal macro).kmmacros (47 KB)

Macro screenshot (click to expand/collapse)

Open specified Apple Note (by execute a macro with parameter).kmmacros is how I call the original macro from within a different macro. The only thing you have to do is give it a parameter (anything you want really), and then put that same parameter in the switch action in the original macro, and then set the variable accordingly. In this example, I use Test Note 1, and then put that same Test Note 1 in the switch action which sets the variable to Notes:::Test Note 1 which opens it automatically without any prompting.
Open specified Apple Note (by execute a macro with parameter).kmmacros (1.7 KB)

Macro screenshot (click to expand/collapse)

2 Likes

Hi @cdthomer and @Undertaker01. I've created another Apple Notes macro that you might find useful. It's based off this macro, but it includes the following enhancements:

  • open one or more notes directly (bypassing the Prompt With List)
  • open a specific note with a Hot Key Trigger
  • trigger from a calling macro

MACRO: Float Specified Apple Notes - Macro Library

1 Like

Hi @_jims, thanks for the heads up. I'll check it out!

It might be good to update your original post with the new version too in case anybody else comes looking for it :wink:

Have a great day!

-Chris

Hi @cdthomer. Since the macro name changed, I did not update the OP. However, it is flagged as SUPERSEDED and a link to the enhanced macro is included.

1 Like