MACRO: Palette Organizer v1.3 (updated Dec 3, 2021)

Hi Dan, sorry to take a while to reply to this. I've been pretty busy myself!

I think the appropriate way to number it comes down to the way it's sorted when numbering. From what I can tell it works as if A to Z were numerical digits after 0-9. (Peter if you're reading this and that's wrong please jump in and correct me!)

So assuming that's correct...

00, 01, 02 ... 09, 0A, 0B ... 0Y, 0Z,
10, 11, 12 ... 19, 1A, 1B ... 1Y, 1Z,
20 ... 2Z,
...
80 ... 8Z,
90, 91, 92 ... 99, 9A, 9B ... 9Y, 9Z,
A0, A1, A2 ... A9, AA, AB ... AY, AZ,
B0, B1, B2 ... B9, BA, BB ... BY, BZ,
C0 ... CZ,
...
Y0 ... YZ,
Z0, Z1, Z2 ... Z9, ZA, ZB ... ZY, ZZ.

So basically the same as how HEX works, but base 36 instead of 16.

That said, that's "only" base 36 = 36^2 = "only" 1,296 combinations, which isn't the 4000 Peter was referring to (since he said it can include other characters as well). That leaves out my third option and includes only the first two (in my original suggestion above). However... I'm thinking 1296 is probably enough! lol.

Given your time crunch - a lot on your plate - how about this for an idea: If we forget the UI additions I suggested, how hard would it be just to create a completely separate base 36 version of this tool - ie. one that just includes the letters as well as the numbers when it renumbers, without an option to turn it off. Frankly, I'll just always use that version.

Or... perhaps you could include a hardcoded "IncludeLetters" boolean somewhere in the code that you can instruct us here to set to true or false depending on whether we want to use numbers and letters (1296 combinations) = true, or numbers only (100 combinations) = false.

As a developer of sorts myself, I'm making the assumption that just that is probably a lot easier than my original suggestion including all the UI stuff. Feel free to correct me if I'm wrong on that one. :wink: But if there's any chance that assumption is reasonable, is this something you might be able to pull off anytime soon?

Mentioning base 36 triggered my brain into action, and it's something I think I can do. Here's the javascript code to go from a number to base 36:

var result = sequenceNumber.toString(36).toUpperCase();
if (result.length === 1)
	result = "0" + result;

So much easier than my thinking. And going the other way is simple too:

parseInt(result, 36);

Adding an option checkbox to the UI is fairly trivial.

I'm trying to finish a YouTube video right now for my channel "The Newbie Woodworker", but I think I might be able to do this when I'm done, which I hope will be today, but I've been saying that for a week now.

So I'll try to work on this when I'm done with the video. If I haven't posted anything in 2 or 3 days, please leave a reply asking how I'm doing, in case I forget.

Dan

1 Like

Hey Dan. That sounds great. As requested, checking in to ask how you're doing. How are you doing? :wink:
David.

Working on some other things. But keep asking. :smirk:

Lol ok. Or... perhaps you can point me to where those additions or changes should be made and I can make them...?

Maybe I can't package up a finished product (or maybe I can?), but even if I make those changes in mine and try them out then I can be a guinea pig for testing and provide you feedback.

OK. There's 2 places (I think).

In the above action there's some code that extracts the sequence numbers from the macro name. It has a regular expression that would need to be changed:

var matches = info.macroName.match(/^(\d\d)?(\))?(.*)/);

Instead of just digits, it would need to get digits and numbers.


The the next action is the Custom HTML Prompt, so obviously you'd need to change it:


When you first look at each set of code, it might look like there's a ton of stuff in there, but it's almost all modularized. For example, you can ignore the KMEditor and KMEngine functions. You won't need to change those. The same holds true for most of the stuff in the HTML file.

Let me know if you have questions. :stuck_out_tongue:

Ahoy. Having made great use of Palette Organizer, I've just discovered I now get a fatal error.

Error in 'KMWindow':
Variable 'palorg_MacrosInfo' not set
Error in 'KMDidShowWindow':
undefined is not an object (evaluating '_desiredWindowPosition.top')

I'm running PO v1.2 with KM 9.0.5 under macOS 10.15.4.

I'd be grateful for any advice. It's a great macro.

β€”Bryan

There's only two things I can think of. The first is, make sure you've selected two or more macros. The second is, make sure you've got KM in "Edit" mode (the button at the bottom of the editor, in the middle.

Let me know if that helps.

Thanks very much for your quick reply. I did a clean reinstall of KM and that's done the trick.

Interesting! I wonder what happened? Anyway, glad you fixed it.

From an email I got from Peter:-
(See also http://www.naturalordersort.org/)

Keyboard Maestro uses a number-sensitive sort, so all your macros that start with 0 or 00 are treated the same, as if they start with 0.

After that they are sorted alphabetically by the next character (which is largely ASCII order in this case, except also case insensitive. So:

space-space, space K, space N, <, =, |, a, A

After that comes the macros that start with the number 1, ie 01 or 1, followed by space N, space R in order.

After that comes the macros that start with the number 2, ie 02 or 2, followed by space K, space O in order.

Then the remaining numbers in order, 3, 4, 5, 6, 7, 8, 99.

This technique was pioneered several decades ago by Stuart Cheshire I believe, and was used in many of my programs for decades. It is now used across the system, including in the Finder.

It allows correct sort order for things like:

Keyboard Maestro supports a specific way of doing manual sorting which is to use a two character code followed by an ), ie:

A0)

These codes will also be hidden in various places (like palettes and menus).

See: https://wiki.keyboardmaestro.com/manual/Glossary?s[]=sorting&s[]=characters

1 Like

hi @DanThomas

hope all is well. I started getting these errors lately when i try and launch the macro

im using version 1.2, any clue how to address this?

thx!

Z

Not a clue. Sorry!

@DanThomas Is there a way to have a space added after the number? Like instead of 01)Macro it would be 01) Macro?

This is an impressive macro, by the way!

There's a reason I didn't do that, although I can't remember why. It was a good reason, though. :smile:

2 Likes

@DanThomas Is there a way to modify the code so I can see the number of the macro? I understand that using the β€œ01)” format, "The macros will be sorted based on the code, but the code will be stripped off before display in the palette (or status menu)."

However, I would prefer to see the number because I like using the number keys to activate a specific macro when the palette is open.

Something like this:
image
Instead of this:
image

So my question is, how can I change the palette organizer to rename the macros with a format like "1)" so the numbers remain visible?

Leave the ) out of it all together
the nn) notation is to sort the macro name display
you want to just NAME your macros "1 macro a"

1 macro a
2 macro b
9 last macro

@jonathonl
Is there a way I can use Dan's palette organizer to number the macros without the ")"?

Sorry but i have not used Dans system, so just code it manually if that is what you want.

Nope, sorry.

1 Like