MACRO: Run or edit recent (edited, created, or used) macros from a list

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:

Screenshot of v7's window

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:

The FULL view, with sortable size data

The NOSIZE view, lacking the size data

The NARROW view, showing just a short date and macro name

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.

7 Likes

Nice,

Can it list the unused first then oldest use to newest use macros? (ie. least used to most recent used)

As in this solution from @ComplexPoint

I honestly have no idea: I just take the output from his macro and show it in a list. So all I can offer is what's there: Created, Edited, and Used.

I could probably figure out how to offer a Sort button, but I don't think I'll be able to get to that today.

-rob.

ok, thanx,

If you get a chance to look at @ComplexPoint's

it also puts out a list, maybe that list could be implemented into your solution...
no biggie in any event.... really...
Thanx for your time and expertise Rob
Cheers

Based on a quick look, the time format is different, so that would require handling in some way. But if there were a Sort button on the one I wrote, then you could sort Used in reverse order, and wouldn't that get you unused?

-rob.

Yes, as long as it was showing all macros and not just a sub-set of them. (ie. just the last 20)
I would need to know that all macros were in the list then yes, if I was able to 'reverse' sort them, that would do the trick! -

I get an error

2024-11-29 14:18:53 Execute macro “Browse lists of recent macros” from trigger Editor
2024-11-29 14:18:55 Action 16462339 failed: Execute a Subroutine action failed to find the macro to execute
2024-11-29 14:18:55 Execute a Subroutine action failed to find the macro to execute. Macro “Browse lists of recent macros” cancelled (while executing Format recently-created macro list).

Ah crud, the export left out the subroutine! One moment.

-rob.

If anyone downloaded before seeing this post, please download again: The original upload was missing the subroutine macro. All fixed now in the download link in the first post.

Sorry;
-rob.

text window stays open and you can see what my HTML window looks like in the screenshot....
all good...

I've uploaded a new one that gets rid of the text window (debugging step left active)—you can fix by just deleting the Display Text action after the three purple subroutine calls in the main macro if you don't want to re-download.

As for the display, I'm stumped: I downloaded the uploaded macro onto two Macs that had never seen it before, and it worked fine on both. What macOS and Keyboard Maestro version are you on?

-rob.

1 Like

hmmmm, I ran for 10 macros and it was good, back to 20 macros and mini html window... I'll work with the new bit you suggested

EDIT: must be something with one of my macros, run for 12 macros, html window good, run for 13 and above, get mini html window...

bro, no worries... it's not that important....

THANK YOU AS ALWAYS man...

Troy

I would guess it's something about the name, a character that's messing up the HTML somehow. I'm not actually filtering the names for HTML characters, so that's possible. If you find out which one it is, please let me know.

-rob.

1 Like

Thanks to an LLM that will rename nameless, here's a version that includes sortable columns—this feature is 100% none of my work, but it seems to work in testing.

__Recent macro browser - sortable Macros.kmmacros (32 KB)

Each column header has up/down arrows for sort direction; click to sort:

Let me know how this works for you—I was impressed that the LLM got the sort working on the first try.

-rob.

1 Like

Do any of your macros, by chance, include " :: " (space-double colon-space) in their names?

-rob.

Cool macro, @griffman. Thanks for sharing. I'll be using it for sure.

I've shared a macro with intersecting features. With my macro, everything is based off the executed date. Also, one of the key objectives was to quickly edit (or run) a recently used macro without taking my hands off the keyboard. Of course the amazing Prompt With List action is a great tool for that job.

One common characteristic with your macro is that it includes some of @ComplexPoint's adapted JXA. :grinning:

Edit a Recently Executed Macro

2 Likes

I actually started this one with a Prompt With List, but I wanted to include the macro group and detailed date, and you can't align text in a Prompt With List. Hence the switch.

What I really want is Prompt With List With HTML and CSS Table Support :).

-rob.

1 Like

no, I have no macros that include " :: " in their name.
But the list that @ComplexPoint puts out has that in every line item, I'm sure you know that.

Yea, and it's what I split on in the regular expression, so I thought maybe that would be causing an issue if it was in a name.

-rob.

1 Like

I have names that include:


`
/
@
[KM]

I am trying to eliminate by running the report and changing macros that have been used but can't seem to find a rhyme or reason...
Although I am sure there is one....

NOTE:

I Think this name is stopping it
z Mod Multi Tick ` x 1

NOTE:
Yes, the ` was cause up to this point.... I removed it and now I'm counting up to see if I can get a list of all 2700 macros (down from 3300!).....
Progress not perfection.... one step at a time...

Yup - it did it, all 2,760 of them. I just 'scroll' to the bottom and I can start working with removing the 'never used / oldest usage' macros....

you ROCK....
and also @ComplexPoint !!!! THANK YOU.... good stuff man....
cheers

1 Like