MACRO: Float Specified Notes, v3.3

PURPOSE

This macro will open the Apple Notes app and float one or more notes (i.e., open each note in a separate window). Thus it provides a convenient method to access frequently used notes.


SETTINGS

local_Favorite_Folders_Titles

The note settings are specified in this text variable. For the required syntax, see the below Comment Syntax Description—SETTINGS (Notes).

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

Otherwise, those using macOS = local_macOSWithModernBehavior or newer, use multiple spaces, and want to avoid space changes when Notes is running in another space, can set this to 1.

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]


HOT KEY TRIGGERS

⌥⇧N : primary Hot Key trigger. This macro processes the SETTINGS (Notes) normally (same as if it was triggered from the KM Editor, a palette, etc.). This Hot Key can be freely changed.

(any modifier combination)+n, where n is any single character, except N, e.g., ⇧⌘W, ⌥⇧⌘3, ⌃⌥⌘Q : These optional secondary Hot Keys will normally be matched (in the three examples W, 3, Q) to prefixes in the SETTINGS (Notes) variable. If no match is found, this macro functions as if it was triggered from the Keyboard Maestro Editor.


TRIGGERING

If this macro is triggered directly it will use the SETTINGS (Notes). If it is triggered by another macro* (a.k.a. a caller), it will use the SETTINGS (Notes) provided by that macro.

*To ensure that a calling macro is structured properly, duplicate macro Float Specified Apple Notes CALLER TEMPLATE and customize the duplicate as needed.


ACKNOWLEDGEMENTS

This macro includes an AppleScript handler derived from a template created and shared by @JMichaelTX: What is Best Practice for Handling Script Errors in Execute Script Action? - Questions & Suggestions


TESTED WITH

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


VERSION HISTORY

( expand / collapse )

1.0 - This was based off Float Selected Apple Note with the following enhancements:

a) open one or more notes directly (with $> prefix)

b) open a specific note with a Hot Key Trigger

c) trigger this macro from a calling macro

2.0

a) Added SETTINGS for window positions.

b) Accommodates n: prefixes in the SETTINGS (Notes) from a calling macro.

2.1

a) Set icon to the Apple Notes app.

b) Updated parsing of text lists.

c) Bug fix: n: was not properly detected unless the line also included $>, i.e., n:$>

2.2

a) Changed primary hot key trigger from ⌥⌘****N to ⌥⇧****N.

b) Changed secondary hot key triggers from ⌥⇧⌘****1 to ⌃⌥⇧****1 and from ⌥⇧⌘****2 to ⌃⌥⇧****2.

c) Included minor performance improvements.

d) Included minor adjustments to window position and size.

e) Fixed a few typographical errors in the comments.

f) Updated TESTED WITH.

2.3 - Modified to accommodate macOS Ventura (v13.x). In this version the Notes app menu item Window>Float Selected Note was changed to Window>Open Note in New Window.

3.0 - Added two settings to optimize macro behavior when using multiple Mission Control Desktop Spaces: local_MultipleDesktopSpaces and local_AlwaysPreventSpaceChanges .

3.1 - Fixed a dialog typo.

3.2

a) Centers the Notes is running dialog and added information for those that do not use multiple Desktop Spaces.

b) When positioning floated windows, existing Apple Notes windows are counted. For example, if two Notes windows are already open when the macro is triggered, the first window opened by this macro will be in positioned as if it is the third window (per the SETTING: local_MultipleDesktopSpaces).

c) If the windows exceed the positions defined, the positions will be reused.

d) updated TESTED WITH section.


Download: Float Specified Notes.kmmacros (212 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 (22F82)
  • Keyboard Maestro v10.2

Float Specified Notes can be triggered (a.k.a called) for another macro. The following is a template that can be duplicated and modified as required.

Download: Float Specified Notes CALLER TEMPLATE.kmmacros (22 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 (22F82)
  • Keyboard Maestro v10.2

7 Likes

I've updated the OP with Version 2.0 of Float Specified Apple Notes.

  • Added SETTINGS for window positions.
  • Accommodates <hk>n: prefixes in the SETTINGS (Notes) from a calling macro.
1 Like

I've updated the OP with Version 2.1 of Float Specified Apple Notes.

  • Set icon the the Apple Notes app
  • Updated parsing of text lists.

Bug fix:

  • <hk>n: was not properly detected unless the line also incuded $>, i.e., <hk>n:$>
1 Like

Nice, thanks for sharing the update. Ever since you posted your original macro I have been using it quite extensively both as a stand-alone as well as embedded in other macros. It’s a very well put together macro!

Hi @cdthomer, glad you are finding it useful. Thanks for the feedback. Your early comments (with Float Selected Apple Note, the predecessor) inspired some of the current features—so extensive I had to even change the macro name. :grinning:

1 Like

I've updated the OP with Version 2.2 of Float Specified Apple Notes.

  • Changed primary hot key trigger from ⌥⌘N to ⌥⇧N.
  • Changed secondary hot key triggers from ⌥⇧⌘1 to ⌃⌥⇧1 and from ⌥⇧⌘2 to ⌃⌥⇧2.
  • Included minor performance improvements.
  • Included minor adjustments to window position and size.
  • Fixed a few typographical errors in the comments.
  • Updated TESTED WITH.

Users of Apple Notes might find this macro also useful: New Apple Note

I've updated the OP with Version 2.3 of Float Specified Apple Notes.

Modified to accommodate macOS Ventura (v13.x). In this version the Notes app menu item Window>Float Selected Note was changed to Window>Open Note in New Window.

1 Like

Hey Jim, glad to see you're continuously updating and posting your macro. I've modified my personal copy so much now that I'm afraid to download your updated ones because I would have to tinker with it to get back to how mine currently works. :sweat_smile:

But one of these days when I am able to again spend more time with my macros like before I'm going to download the latest version and check out all the cool updates!

1 Like

I've updated the OP with Version 3.0 of Float Specified Apple Notes.

Added two settings to optimize macro behavior when using multiple Mission Control Desktop Spaces:

  • local_MultipleDesktopSpaces, and
  • local_AlwaysPreventSpaceChanges.
1 Like

I've updated the OP with Version 3.2 of Float Specified Apple Notes:

  • Centers the Notes is running dialog and added information for those that do not use multiple Desktop Spaces.

  • When positioning floated windows, existing Apple Notes windows are counted. For example, if two Notes windows are already open when the macro is triggered, the first window opened by this macro will be in positioned as if it is the third window (per the SETTING : local_MultipleDesktopSpaces).

  • If the windows exceed the positions defined, the positions will be reused.

  • updated TESTED WITH section.

I've updated the OP with Version 3.2 of Float Specified Notes:

  • Changed the name from Float Specified Apple Notes to Float Specified Notes.

  • Improved the Notes is running dialog.


1 Like

Hi Jim, I'm having trouble understanding the syntax info and wondering if you could possibly give me some guidance on specifying a note I'd like to float. All my notes are iCloud notes with my iCloud account listed at the top of the left column. So the left column reads:

"All @mac.com"
"Notes"

When I select "Notes," pinned at the top of the notes column is "TO DO LIST" which is what I'd like to float. Where/how do I fill in that info in the appropriate fields?

Hi, @AppleTooPlus; welcome to the Keyboard Maestro forum.

When I see someone new to the forum, I like to share a few links that are helpful:

Looks like you haven't created any folders in the Notes app (File > New Folder). That's not a problem, but something you might find helpful if/when you accumulate a lot of notes.

The note folder specification is actually optional. If you had hundreds of notes, retrieval might be slightly faster if you specified the folder.

For your case, if you want the note to always float when the macro is triggered, then specify the following:

Keyboard Maestro Export

The $> is an indication that the note should be always floated. (It's actually optional if local_Favorite_Folders_Titles includes only one entry.)

Note also, that the specified text should be the entire first line, or a substring of the first line, of the desired note. The match is case insensitive.


The macro is designed to provide additional options. For example, with:

Keyboard Maestro Export

When the macro is triggered, Scratch Note would be immediately floated, and the other two notes would appear in a Prompt With List (PWL) menu. If one of them was subsequently selected, that note would also be floated.


There are a few other features. For example, with:

Keyboard Maestro Export

  • If the hot key trigger did not include 1 or 2, Scratch Note would be floated, and the three other notes would appear in a PWL menu.

  • If the hot key trigger did include a 1, Scratch Note would be floated. The other three notes would not appear in a PWL menu.

  • If the hot key trigger did include a 2, TO DO LIST would be floated. The other three notes would not appear in a PWL menu.

1 Like

Appreciate the info, Jim! I actually have an extensive list of note folders and subfolders but didn't include examples which may have been a little confusing.

I tried entering "$>TO DO LIST" string in the SETTINGS (Notes) box:

--but upon running the macro, 2 things happen: 1) the Notes app appears invisible when opened by the macro (see below - I assume this is as is should be as part of the 'floating' function)...

...and 2) the "TO DO LIST" note is not selected when I make Notes visible, nor is that note floated. I tried other titles from other notes, but none of them select or float a note. Any suggestions?

Very odd, I've never seen anything like that.

The second screenshot is actually the Mission Control. Might you have a conflict between that macOS keyboard shortcut and the macro trigger?

I'd try the following:

  1. Restart your Mac.

  2. Initiate the macro from the Keyboard Maestro editor, not using a keyboard trigger.

  3. Initiate the macro with and without the Notes app already running.

  4. Maybe delete your copy of the macro, and download and install it again.

It certainly seems that there is some conflict occurring. Please try these things and report back.

The Mission Control window I was just showing to demonstrate the presence of the Notes app being open (but invisible). I've only been initiating the macro in KM (without the use of keyboard triggers).

I deleted and reinstalled 3.3 of the macro, then tried restarting and initiating again from KM (with no other applications running). After I did this, nothing happened. When I go into the app switcher, the notes app is faded. When I click on the Notes app, it shows up with whatever note I had last selected (not the TO DO LIST).

If it helps, I'm running Sonoma 14.2.1 on a MBP 16" M1 Max. Very mysterious! Any other ideas? I assume that in running the macro with the string entered, the note "TO DO LIST" should simply pop up somewhere on the screen?

Thanks for that information. Coincidentally, I have the same hardware and macOS. I'm using Keyboard Maestro v11.0.2.

Yes, this is indeed odd. I suspect that you are encountering some sort of privilege issue with Keyboard Maestro controlling the Notes app via AppleScript.

I've got three test macros for you to try.

Before triggering Notes Test 1, quit the Notes app. When you run the macro, the Notes app should open.


Download: Notes Test 1.kmmacros (1.7 KB)

Macro-Image


Before running the next two macros:

  1. Open the Notes app and select any note except TO DO LIST.
  2. Quit the Notes app.

When running Notes Test 2 and Notes Test 3, the Notes app should open and TO DO LIST should be selected. Notes Test 3 more closely represents the AppleScript within Float Specified Notes.


Download: Notes Test 2.kmmacros (1.9 KB)

Macro-Image


Download: Notes Test 3.kmmacros (5.0 KB)

Macro-Image


Correct. With the Float Specified Notes you should see this...

TO DO LIST

I tested out each of the macros as specified.

Notes Test 1 worked as described -- it opened Notes.

Notes Test 2 opened Notes but then failed to choose a note with "TO DO LIST". I selected a different note and double-checked to make sure there were no extraneous spaces or characters in the "TO DO LIST" title. I also tried subbing titles of other notes but alas nothing. No matter what I put in, when Notes opens, the note that was last selected before closing the app remains selected.

Notes Test 3 -- same result as 2 except that the Notes app icon remains faded and the app window invisible until actively selected.

"TO DO LIST" is pinned. I tried un-pinning it to see if it would make a difference (it did not.)

Here's a screen capture of the top of my folder column if helpful:

Screenshot 2024-01-01 at 3.16.49 PM

Note that I am also using KM 11.0.2.

Hum, Notes Test 2 is a very simple:

tell application "Notes"
	activate
	tell (get every note whose name contains "TO DO LIST")
		set theNote to its first item
		show theNote -- also selects the note
	end tell
end tell

I suggest inserting that script is the macOS Script Editor and run the script.

If that doesn't select TO DO LIST, then I'm stumped. Please try it and report back.