Learning & Using AppleScript & JavaScript for Automation (JXA)

Are we expecting any update to KM which will speed up the processing of AppleScripts on KM Engine?

Hard to imagine how that could be done ...

Depending on what you are doing, Javascript can be faster for some purposes.

1 Like

I don't know about any changes to Keyboard Maestro, but, the following could speed up your scripts:

  1. Save the script text in the Action to a compiled file (.scpt), and change the KM Action to use that file.
  2. Execute the script file using the Apple Scripts menu, or FastScripts.
  3. Rewrite the script to avoid known bottlenecks like the Finder.
  4. Make use of ASObjC.
  5. Use professional script libraries (like those from @ShaneStanley) and/or Scripting Additions (like Satimage.osax).
  6. Finally, review and optimize the design of your script.
1 Like

Basically, no. @JMichaelTX gives a lot of good advice on possible ways to improve the performance, but no changes to Keyboard Maestro are likely to help you.

You need to figure out what is causing the performance issue, there are a bunch of plausible places to look:

  • Keyboard Maestro has some overhead. Run a trivial script and you can see the base overhead.
  • Compiling the script can be expensive - Keyboard Maestro will compile your script from text each time it is run unless you select a compiled script file.
  • AppleScript is relatively slow
  • AppleEvent interprocess communication is relatively slow
  • The script itself could be using poor algorithms
  • You could buy a faster Mac, or one with more memory, or a faster HD, depending on what the bottlenecks are.

There are many ways you might improve the performance of a macro that is executing an AppleScript, but there are no plans to make Keyboard Maestro magically run an AppleScript faster.

What?!? An online study course for AS beginners? Where's the PayPal link?

Seriously, a wiki or perhaps a step further, a devoted space for us beginners (dedicated Outback Lounge space?) to gather and learn from each other along with the various AS bits scatter around this forum Collected and Organized would be useful and valuable.

This as in other places (here and outside this forum) is a mix of listening in on the hobnobbing among wizards from which some productive gleaning can come and some really well written 101 materials.

And yes I recognize this is a BIG ask as everyone has a life and this is forum is fundamentally based on acts of generosity of which fortunately there is very much.

I for one would paid a good fee or ongoing charge to participate. Money aside, someone would need to have a deep interest in or commitment to educating to take this on. Being very skilled in an art and communications that leading others to developing their skills are very different activities especially given how differently people develop.

1 Like