A thought about the site's growing discussions of scripting

I agree with Dan.

Keyboard Maestro is an excellent instrument which can be used at varying levels in a wide range of contexts.

That means that this is a busy watering-hole, visited by a quite wide range of creatures, all with very different needs and skill sets. For any given problem, a script may provide the best solution for some (quicker to write), while a series of actions may provide the best solution for others (easier to write).

Unlikely to be any value I think, in trying to normalise the approach – the thing is to optimise it for each user. No one would really benefit if discussion of Execute Script actions was discouraged. Scripters would just go elsewhere.

( See under the tale of Procrustes – who ran a much less popular and successful business – not an approach to emulate … )

3 Likes

Hmm…

Peter has put significant effort into providing Keyboard Maestro with comprehensive abilities to run many scripting languages.

Actions:

  • Execute a JavaScript For Automation
  • Execute a JavaScript in a (or all) Custom Prompts
  • Execute a JavaScript in Google Chrome
  • Execute a JavaScript in Safari
  • Execute a Shell Script (any scripting language that can run from the shell)
  • Execute a Swift Script
  • Execute an AppleScript
  • Search & Search/Replace (Clipboard & Variables) with Regular Expressions

It would be a shame to waste it.  :sunglasses:

-Chris

2 Likes

People should use whatever facility they are comfortable with.

Where it is possible and appropriate, its great to use native Keyboard Maestro actions. But some folks are very comfortable with scripts and that is where they turn for a solution. When someone asks on the forum, the most important thing is that they learn something, and the next most important is that they get a solution to their immediate problem.

If someone clever like @ccstone or @ComplexPoint post a script that solves a problem that you think could be well solved with native actions, by all means post your solution and compare and contrast (respectfully!). Everyone can then learn a bit and the OP has multiple solutions to choose from, probably with different pros and cons that may make one or other better suit their needs (probably in ways that have not been expressed in the original query).

So folks on the forum can script as much or as little as you like - as long as it is tangentially related to Keyboard Maestro, then it’s fine by me. If things get excessively out of control, then I will try to gently let people know, but it’s hard to imagine how more solutions in whatever form can be bad for people.

1 Like

I learn so much from threads with multiple solutions from multiple contributors. They're the most valuable to me by far.

1 Like

As someone new to KM and very new to scripting, I appreciate the multiple approaches to solving problems, and the value of this forum for me lies in exactly that, but I’m not sure if I can ever use KM to its full potential.

For instance, in the KM macro to convert URL contents to PDF that I requested for help and @JMichaelTX so graciously figured out a solution, my follow up question was whether the desired result could’ve been reached without the use of any scripting, since I do not know any.

The issue for me though is that when solutions that are provided that use scripting of any sort, I feel extremely uneasy about the simple fact that I’m not using KM to its potential and that I need to have some sort of CS background to make it do any meaningful work. As you can imagine, this isn’t the best way to appreciate the power that lies within KM. For someone starting out with KM, this complexity might be a reason enough to not tinker or work with it and may be off-putting.

All that being said, I have a small suggestion:

Would it be possible to put together a wiki list of resources that can guide folks to recommended sources of learning the various scripting languages? I’m sure this would be extremely useful and we’ll have a growing repository of tried and trusted resources. At least that way for people like me who are willing to learn and tinker, we know exactly where to go to seek help in the future.
-Sid

You should know that the large majority of use cases for Keyboard Maestro do NOT require any scripting. KM provides many Actions that otherwise would have required a script.

Having said that, there are definitely some cases that require scripts. That's why KM also has Actions for "Execute Script".

The biggest need for scripting generally falls into these areas:

  • Web page manipulation (like getting all links on a page)
  • Automation of Mac apps (getting specific data/records/text into and out of an app), and integrating Mac apps
  • Unusual manipulation of the User Interface elements of an app (like showing the PDF menu on the Print dialog)

Please don't feel intimidated by the use of scripts. For the most part you won't need them. When you do, we're here to help.

Have you seen:
Scripting [Keyboard Maestro Wiki]

This is the main page for Scripting, with links for each scripting language, and other resources.

If you don't find what you need there, please let us know.

1 Like

Hey Sid,

Like most users you picked as an early project a complex task that was way beyond your competence with the given tool. This is like trying to rebuild a Mopar 426 HEMI without any tools or mechanical training.  :sunglasses:

BTDT many times.

It's frustrating, but it drives me to learn new things.

Don't worry too much about scripting for now. Learn Keyboard Maestro's architecture and nomenclature.

Don't ignore scripting either – watch what comes up on the forum – and see where it's useful.

If you haven't already – turn on “Mailing list mode” in your Keyboard Maestro forum preferences:

I look at everything and archive anything useful.

If something looks interesting enough to read carefully I jump onto the forum, so I have a broader overview of the topic.

Of course I have a script for jumping from the selected message in Apple Mail to the post on the Keyboard Maestro forum:

See this post.

Don't worry too much about not using Keyboard Maestro to its full potential – not even Peter does that.  :smile:

-Chris

3 Likes

I only started scripting and programming less than a year ago, but I feel like I’ve accomplished so much partially because KM has always been a central part of everything I do. In fact, I don’t think I would have had the energy to get into any of this stuff if it weren’t for KM. It’s amazing how it can have so much potential for advanced users but at the same time be so easy for beginners.

4 Likes