How to batch create palettes of simple one action (open URL) macros based on a table in Numbers exported to CSV

Hello,
I have many 50+ favourite Notes/Docs in Bear, DevonThink and Scrivener, and would like to create palette of macros linking to those notes/docs.
Each macro is very simple consisting of one title (the title of the note/doc) and one URL action (the link to the note/doc).
My idea is to

  • create a 2 column table in numbers with the note/doc title on the left and link on the right.
  • export as CSV (probably easier to read for KM)
  • create the batch of macros based on that CSV.
    My initial idea was to create a template XML (created from a one action (open URL) macro), but that failed.
    thanks in advance for your time and help

Hi Ronald
I'm not sure I understand what you want to do. I also use DT and Scrivener and need links to specific docs that I can find quickly. A favorites list, so to speak.

I just use a (floating) RTF window that I show/hide as needed with these links that I can create in 2 seconds. I can group them, color them, move them, search for them or delete them as I wish.

It's basic, but it's quick and works well. So if it's just about opening a specific doc ...

I can't show anything “productive” here, but it basically looks like this.

image

1 Like

I think you could totally do this.

First create a couple of open URL actions configured how you would like. Copy them both as XML (You use two so that the coped XML will include an array wrapper around the two actions. Once you grok the syntax you'll be able to make as many as you like.

Second, use your skills to parse through your list of URLs (e.g. with a "For Each") and build up the XML for the whole array of actions.

Copy that, and paste it into the macro where you want it. 30-40 minutes tops. Good luck! :grin:

Edit.. Whoops sorry, I missed your requirement for a palette. Forget about the array, just create a macro with a single "Open URL" action. Follow the original plan and you will have a Macro Group with a separate macro for each URL.

Now you just set that group to display as a palette and you're golden.

1 Like

I will give it a try. thank you

thanks very much. I had tried it with a Bear markdown floating window, but did not like the clicking.

Does that mean you don't want to use the mouse, but the keyboard?

1 Like

yes, palettes are very fast

1 Like

Hello again @Frankb. You were 100% right as usual. I have been playing around with this palette idea including a macro to generate it, and it's not working. I took your advice and am very happy with all the advantages you describe. In the future, I will think twice before not taking your advice. Vielen herzlichen Dank !

Haha, I'm not always right. Especially as this is actually about a preference, keyboard or mouse.

But I have an idea how you could also do it with the keyboard. By pressing a letter, just like with a palette. But I have to try that out first.

Do you also use BTT? Von KM verstehe ich nämlich nicht viel mehr als die Kuh vom Melken. :smirk:

1 Like

very funny. BTT: yes, I use it often. thank you

Is there a benefit to a palette (besides its prettiness!) rather than a "Prompt with List"? Otherwise it sounds like a job for a Conflict Palette -- use AppleScript to generate the macros from your CSV, giving them all the same hot key trigger...

1 Like

Yes, good point, but as @Frankb mentioned, there are so many and so frequent changes, that a floating markdown Bear window seem more convenient. thank you for your post.

Not a Bear user, but if a Note is just markdown it shouldn't take to much work to write a macro that parsed the Note and extracted links and link names to present via a "Prompt with List".

The overhead of creating, then deleting, 50+ macros via AppleScript every time you ran the macro is a little too much, even for me :wink:

1 Like

Yes, you are right and it's something to consider. The only downside (for me) with prompt for list is the obligation to type and to remember the title of the note you are looking for as opposed to seeing. It's something i am constantly struggling with and I change my mind every week.
Even what I just said is wrong because it's possible to scroll down the list. There again there is the problem of the small prompt for list window.
As you can see I am going in circles.

1 Like

If the links are in a table of a text document, they can be easily changed and you don't have to search for names because you can see them. At the same time, numbering allows you to select a link with the keyboard. This can be done in different ways. Probably also with KM, but certainly with BTT.

image

1 Like

VERY interesting. Could you elaborate on how it is done with BTT ? I have no clue how you would trigger the links using the numbers thank you

If I had to try it with KM with my non-existent knowledge, I would make this consideration.

The table and thus the numbering is always in the same relationship/position to the top left corner of the window. It should therefore be possible to move the mouse (safely and quickly) to 1 or 2 ... actually to the link. After that, a left click is probably not a good idea, because it doesn't work if the link is already highlighted.

What should always work is the command in the context menu of the link. At least that's the case with BTT.

Whether this is really a good idea, I don't know. It's the only one I have to have maximum flexibility with the links.

1 Like

very fancy and interesting. I had never thought about using coordinates. I will give it a try. Thank you @Frankb !

OK -- so, building off our previous work with Bear, here's an approach that gets the complete text of a particular Note then extracts the URL from the table row with the specified number.

It assumes that the Bear Note contains markdown table like this:

| Num | Link                                                         |
|-----|--------------------------------------------------------------|
| 1   | [The BBC](https://www.bbc.co.uk)                             |
| 992 | [KM Forum](https://forum.keyboardmaestro.com/latest)         |
| 13  | [KM Manual](https://wiki.keyboardmaestro.com/manual/Single_Page_Version) |

...though it would be easy enough to change the regex if your link entries are different.

In both versions of the macro you'll need to set the value of Local_noteID to the "Identifier" (UUID) of your Bear Note. And check that Local_dbPath is correct for your Bear database. As written they pop a "Display Text" showing the URL.

This one uses a "Prompt for User Input" so you can see the number you are entering:

Find and Open URL (dialog).kmmacros (8.3 KB)

Image

This pair of macros does away with the dialog. The first is just an "activator" for the second, with a hot key of ⌃⌥⇧⌘U:

Activate Find.kmmacros (1.5 KB)

Image

...while this is the meat -- once activated it will swallow and store a sequence of typed numbers, until you hit Return to go find the URL or ESC to cancel the process:

Find and Open URL (no dialog).kmmacros (10.8 KB)

Image

Upside -- no annoying Prompt :wink:
Downside -- you can't see the number you are entering :frowning:

As usual for me, little or no error checking -- you'll probably want to at least cater for the regex not finding a match since, as it stands, you'll have to go and clear the Global_selectedNumber yourself...

3 Likes

WOW ! thanks very much !! I will have a look.