MACRO: Note Picker, v1.1

PURPOSE

This macro will open the Apple Notes app to a: 1) selected folder, or 2) selected note. If a note is selected, it is opened in a dedicated window (a.k.a. floated).

The macro has two modes:

  1. The macro is triggered and no other information is provided. In this case, a Prompt With List appears that includes the Apple Notes app folders followed by the note titles. To distinguish the two groups, folders are preceded by f/ and the note titles are preceded by t/.

  2. The macro is triggered and f/ folder_substring or t/ title_substring is supplied via the macro %TriggerValue%. This can be done from another macro using the Execute a Macro action or another macOS application via AppleScript (e.g., Alfred and Bunch) using this template:

-- Note Picker

property theP : "f/ folder_substring"
--property theP : "t/ title_substring"

tell application "Keyboard Maestro Engine"
  do script "A3DF7C60-CF4B-4E64-AD35-72BAB6937E9F" with parameter theP
end tell

In this case, the macro will search for matching folders or note titles. If only one match is found, then the macro will immediately open the folder or note. If more than one match is found, a Prompt With List will appear so that a folder or title can be selected.


SETTINGS

local_WindowPositions_x_y_w_h
The window positions and size are specified in this text variable. For the syntax, see the below Comment Syntax Description—SETTINGS (Windows).

local_MultipleDesktopSpaces : 0|1
Two groups can change this setting to 0 and ignore the next setting, local_AlwaysPreventSpaceChanges:

  1. Those NOT using multiple Mission Control Desktop Spaces
  2. Those using multiple Desktop Spaces, but do not care if running this macro initiates a switch to another Desktop Space, i.e., the space where Notes is already running
    1 [default]

local_AlwaysPreventSpaceChanges : 0|1
If set to 0 and a Desktop Space change could occur, a prompt will appear with three options: 1) Cancel, 2) Do Not Quit 𝗡𝗼𝘁𝗲𝘀, 3) Quit 𝗡𝗼𝘁𝗲𝘀 and Reopen. The latter will ensure that the new note opens is the current Desktop Space (with the trade-off detailed in the dialog). If set to 1, a dialog will not be presented, but the Notes app will behave the same as if Quit 𝗡𝗼𝘁𝗲𝘀 and Reopen had been selected.
0 [default]


TESTED WITH

• Keyboard Maestro 10.2
• Ventura 13.4.1 (22F82)/MacBookPro16,1
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445


VERSION HISTORY

1.0 initial version

1.1 Bug Fix: If this macro was run in Mode 2 and the specified title_substring yielded only one matching note, an AppleScript error resulted. This was caused by a typographical error in the Execute an AppleScript action that searches for matching notes.


Download: Note Picker.kmmacros (179 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.4.1 (22F770820d)
  • Keyboard Maestro v10.2

Mode 1: Triggered and no other information supplied, e.g., triggered by a hot key.


iMode 2: Triggered via an Alfred Workflow:


For more information regarding Mode 2, see: Using Alfred to Trigger Keyboard Maestro Macros


Mode 2: Triggered by a shell script

shell script ( expand / collapse )
#!/bin/bash

# Get the script name without the path
script_name=$(basename "$0")

# Check if the script begins with  "Float Apple Note_"
if [[ $script_name == "Float Apple Note_"* ]]; then
    # Extract the portion of the script name after "Float Apple Note_"
    apple_note_title=${script_name#"Float Apple Note_"}
    
    # Remove the file extension
    apple_note_title="${apple_note_title%.*}"
    
else
    echo "Script name does not contain the Float Apple Note_ prefix."
fi

osascript <<EndOfScript

-- Note Picker 

property theP : "t/ $apple_note_title"

tell application "Keyboard Maestro Engine"
	do script "A3DF7C60-CF4B-4E64-AD35-72BAB6937E9F" with parameter theP
end tell

EndOfScript

2 Likes

I've updated the OP with Version 1.1 of Note Picker:

Bug Fix: If this macro was run in Mode 2 and the specified title_substring yielded only one matching note, an AppleScript error resulted. This was caused by a typographical error in the Execute an AppleScript action that searches for matching notes.