With a zillion KBM macros in my library, I find that I use trigger macro by name more and more often. It consists of a simple one action macro.
The only problem is the variable and sometimes up to 5 seconds long it takes for the Trigger Macro by Name search box to appear.
I was wondering if there is any way to speed up the action and make the process more consistent, or could I get the same result by using an AppleScript or shell script?
No idea. Without knowing the cause of the slow down, I wouldn't know where to start.
You would need to use the Activity Monitor to get a sample of the Keyboard Maestro Engine during the period that you call up Trigger Macro by Name and have the slow performance.
A Studio M1 is a stupendously fast Mac, so the only reasonable cause would be some sort of caching that isn't done.
In my macros, I have around 500 active macros that might be displayed, but the Trigger Macro by Name appears virtually instantly, so even with ten times as many active macros it would be a fraction of a second, nowhere near 5 seconds.
You would need to launch the Activity Monitor, start sampling the Keyboard Maestro Engine, and then trigger the Trigger Macro by Name macro. And it would have to be slow on that occasion. And then the 10 second monitoring of the Keyboard Maestro Engine might tell us something.