When I saw @ComplexPoint's N Most Recent Macros macro, I knew I wanted to have its output in an HTML prompt window, where I could easily run or edit any of the listed macros.
Now, 1500 edits and many releases later, I think I've reached the end, at least as far as I can go with this macro…which is actually now two macros. Yes, two…
Recent Macro Browser - v7
Really, there's no reason to use this one any more—it's here for historical purposes, but now hiding in a details section :).
The out-of-date and now irrelevant first version
__Recent Macro Browser - v7 Macros.kmmacros (51 KB)
The seventh release of the first macro I wrote. This one features all the speed increases I found in version six, plus I cleaned up a lot of stuff, including the HTML so the table looks much nicer:
This macro is the one to get if you do not care about seeing size information for your macros and want to see thousands of macros in the table at once—maybe up to about 1,500 macros or so. You see, that's why there are two macros now.
I have now overcome the environment size limitation that caused the above issue by avoiding variables as much as possible. There's now really no reason to use the non-Plus version any more, but I'll leave it for posterity. Hiding in the section below are details on the issue I ran into, due to the large amount of data being manipulated.
The 'environment too large' issue
While adding in the size data, thanks to @ComplexPoint's revised JXA, I discovered that the HTML-coded variables that lay out the table are very large. So large that they're bumping up against the environment size limits in Keyboard Maestro. The original macro, without the size details, stays just below 400KB when it loads all 1,200 of my macros.
But with the size information included, the file swells to over 400KB, and the table goes blank, because the variables are too large for the environment. So what to do, what to do? Technically, there's an approach that saves the data to files and reads it in as needed in the tables, but that's way beyond my oh-so-limited Javascript skills.
So what I did is forked my own macro :). The no-size version remains, and I then started working on the version with size information, which became…
As noted, that's no longer an issue, and I recommend everyone start using…
Here's the version I recommend:
Recent Macro Browser Plus - v2.1
— Recent Macro Browser Plus - v2.1 Macros.kmmacros (116 KB)
Jan 2 2025: v2.1 released. New feature, control over window centering.
Dec 7 2024: v2 released
The Plus version includes macro size information, of course, and a choice of three viewing modes:
As you can see in the FULL view screenshot, the size column is there, and fully sortable. I made the executive decision to list everything in KB; if you happen to have multi-gig macros, I'm sorry but you'll have to make that column much wider :).
Also new in this version is a much simpler way to set the macro count limits for each view mode. Before you had to open each view's settings and find the macro limit; now it's in one box at the top of the macro:
Edit just the numbers, and the macro will parse each line to set the macro limit for each view mode.
v2 of the Plus macro now also includes optional name truncation: You can specify a character length cutoff for the names, making it possible to have a very narrow table, as long as you have enough characters to identify each macro. (This is off by default.)
How to use
There's a brief how-to in the macro, so please read that for help getting started. There are no variables that must be set before you use the macro; it will run as is after install. The how-to explains how to set the various options.
To change the view, change the first green-box variable in the macro to one of FULL, NOSIZE, or NARROW.
Once the window is onscreen, click the buttons at the top to choose between which set of macros to view, and that's the extent of the interface :). Note that this is not updated in real time when you click the buttons: I load the data when the macro launches, then just display those results as you click each button. To update the lists, you need to run the macro again.
Each of the three views have their own set of customizations to control the window's appearance:
- Number of macros to return (can be different for each view)
- Font size for table data
- Font size for the header text at the top right of the window
- Table row height and row padding
- Window height and width
- Initial active category (created, edited, or used) and sort order
The settings are hiding in the three expandable teal-colored boxes in the macro. Each of these boxes contains nine settable values to control the window's appearance in each view—27 settings in all!
Thanks to others!
This macro is made with 100% full credit to @ComplexPoint! I couldn't ever have written what he wrote; I just used his macro as it was (with one minor change to catch macros with backticks in their names) and forced his output into the format I wanted to use it in. Kudos, Rob, for a very slick bit of code!
And thanks to @_jims for the invaluable testing—he was the one who noticed the limitations on the macro counts. I relied on an LLM to create the sortable table columns; that Javascript is 100% nothing I wrote, but it seems to work quite well.
-rob.