I have one or two thoughts. First, the editor itself doesn't know when the Engine runs a macro. The Engine would have to have a record of each macro run. Fortunately, there is at least one such record, and that is the Engine log file. I think it would be possible, perhaps even easy, for a macro to look for the "last triggered macro." There are two problems with that idea. First, macro names are not "unique" which means that if you had two macros of the same name, there's no way to know which one was the one that ran. Second, any macro that wants to find the "last triggered macro" would actually have to look for the "second last triggered macro" because the macro doing the looking itself is a triggered macro! Perhaps now you can see why this is tricky.
However there's probably an easy solution. You could manually insert a "record this macro" statement at the beginning of all your macros (except for the macro which runs the last triggered macro.) I think this would get you what you want. You could solve the "unique" problem by saving the UUID of the macro instead of its name. It should be quite simple, inserting a statement like this at the top of each of your macros that you want to track:
A small change to the macro provided by DanThomas should work. Instead of going to the Menu Item titled Last Edited, going to the Menu Item called Last Used will open (of course) the last used macro.
That's great information! But I suppose that means the Editor has access to some Engine data source besides the Engine log file, because the Engine log file doesn't provide a UUID for the last macro. Any idea what that might be?
Well, it could ask the engine directly, of course. But you could also find this out in the "Keyboard Maestro Macro Stats.plist" file in the Application Support folder. That's what I use here, although I haven't released this yet:
The last triggered macro is presumably always this one, so we may often be looking for the penultimate trigger event
The entry to the Keyboard Maestro Macro Stats.plist file is presumably written when a macro concludes (rather than starts), so if two are running we may need to distinguish between most recently started and the most recently finished. (which may be the same).
For a macro which lists the N most recent trigger events recorded in Keyboard Maestro Macro Stats.plist, with the names and UUIDs of the triggered macros, see:
Running the Macro you shared resulted in this error:
Execute a JavaScript For Automation failed with script error: text-script:0:15: script error: Error on line 1: SyntaxError: Return statements are only valid inside functions. (-2700)
On a related note, I cobbled together a macro that presents a list of the ten most recently executed macros and, if one is selected, Keyboard Maestro opens and the macro is selected for editing.
Thanks! This macro is a great workaround in the meantime…
Would ideally love to skip the prompt and just open the last triggered macro. I'm fiddling with this now, if I'm able to get it to work I'll post the macro here so future folks can find it, thanks again!