Macro to display "Last Used"


Here's the test case. I run "MacroA" and it does not behave as expected. I would like to trigger a macro that switches to KM and displays "MacroA" so I can investigate it. I've created a "Display the Last Used" macro which switches to KM and selects menu option View > Selected Macro > Last Used. However, the macro "Display the Last Used" results in displaying itself, which is in fact, the last used macro.

So, is it possible to have a trigger that displays "MacroA"?

Currently KM tracks Last Edited, Previous Edited, Next Edited. It would be nice if KM could also track Last Used, Previous Used, Next Used.



I think the only guaranteed way of doing this is from outside KM -- for example, with this AppleScript:

tell application "Keyboard Maestro"
end tell

tell application "System Events"
	tell process "Keyboard Maestro"
		keystroke "u" using {command down, option down}
	end tell
end tell

You could save it as a script and run from the Script Menu menu bar item, as an application and keep it in your Dock, etc.

The problem with doing it from inside KM is that you're reduced to using the KM Engine log, which records macro names (rather than, say, macro UUIDs) -- so if you've two macros with the same name you may reveal the wrong one.

1 Like

Thanks @Nige_S for the quick response and the AppleScript solution. Much appreciated. :slight_smile:

Here's another way you might want to try. It'll throw a prompt with a list of recently-triggered macros (20-60, depending on your failure rate!), most recent at the top, each marked with a tick for success and a cross if it failed:

Double-clicking an Xed macro will open up a new KM Editor window at that macro, with the action that caused the error selected. Double-clicking a ticked macro will open the macro with that name in a new Editor window -- if there's more than one with that name then there will be a new window for each.

Go to a Recently Triggered Macro.kmmacros (11.2 KB)


It has not been extensively battle-tested, but there's nothing destructive in there so it shouldn't cause any problems. And it was rather quickly thrown together -- expect improvements (or outright dismissal :wink: ) once the Forum gets their hands on it.

1 Like

I don't have the scripting prowess for approaching a situation like this with those capabilities, so I typically end up using KM to accomplish the goal using built-in interface capabilities.


For both of the Select Menu Item uses, the gear menu has been used to disable the options for Failure Aborts Macro and for Notify On Failure. On my system this works, but macros like this can need pauses added in on other setups.

Last Used Macro.kmmacros (4.6 KB)


Nice! I was not expecting this. It's cool to see a chronological list of recently executed macros. Very clever use of the KM engine log. I'll keep the macro as another tool to use. :). Thanks again!

Geeze, why didn't I think of this method? It's certainly within my capabilities. :sweat_smile:

Hi @NaOH, I added a couple of actions to your macro after the 'last used macro' is selected:

  • Reveal Parent Group
  • Sort Macros by Name

Last Used Macro Macro (v10.2)

Last Used Macro.kmmacros (7.1 KB)

1 Like