A thought about the site's growing discussions of scripting

These need to be alphabetized. If there were a way to do it it would also be good to group them into related topics. (All scripting tags, all GUI tags, all Mac application tags, etc.)

Tags are more useful because more than one tag can be assigned to the same topic, whereas a topic can belong to only ONE forum category.

The way @peternlewis has designed the forum categories is for each category to represent a very broad classification.

So it is easy enough to search for what you want:

category:macro tag:jxa

will get you all of the JXA related macros.

I tend to agree with you on this, but the Discourse forum designers seem to think it is more important to present the tags most used first, and we have no way of changing that.

If you want an alphabetic list, go to the tags page, and click on sort by name.

The scripting discussed here has pretty much all been related to applying the many different scripting languages to automating processes of some sort, and hence it is appropriate on this forum.

And I do agree there is a risk that all the scripting discussion is overwhelming for users just wanting to solve some simple problem, and that risk is not mitigated by Tags. It would be reduced somewhat if there was a Scripting category and the scripting discussion was confined to that category, but I don't see how that would work since most scripting replies are replies to non-scripting specific questions of how to accomplish something. If I look at just the General category:

https://forum.keyboardmaestro.com/c/general

there are only a handful of topics that are really scripting-specific, the rest are topics asking how to do something that may or may not use a scripted solution.

As for a multitude of categories, I general find that more categories either requires significantly more maintenance in changing categories of incorrect choices, or significantly more education of the visitors (which I am not in favour of requiring) and tends towards problems of never quite being sure where things really belong.

For the most part, I think the value of the scripting knowledge shared on this forum outweighs the downside. And I presume novices looking at the forum a) won't be reading every post and thus will skip long drawn out debates on scripting, and b) will be scanning through the general or macro category looking for something interesting, or c) will use search to find what they are after, or d) failing that will post a question.

Oh, and in an ironic twist, this topic itself belongs in the meta category, not the general category… :wink:

2 Likes

Y, meta & y ironic. Apologies.

Y, I forgot Swift

For my part, I am probably a happy KM user largely because I can't script. So when the solution to a question is a script I tend to feel we haven't advanced our ability to wrangle with KM.

I perfectly understand that scripting provides more elegant/quicker/shorter solutions but, to adapt an analogy I started elsewhere, it's like I'm taking a German class and people try to help out by making suggestions like "have you tried writing it in Spanish?" :slight_smile:

That said, I have been very happy copying mostly Apple-scripted solutions and hacking them about on my own (though JXA leaves me standing.)

I wouldn't want to see the scripting discussions disappear and I'd love to see more focus on KM-wrangling sometimes... Is that having my cake and eating it?

4 Likes

You would have both if scripting discussions were in a different category.

1 Like

This makes perfect sense. Access to scripting is key to complex automations, and it fills those gaps that Peter hasn’t thought of or isn’t interested in - such as very tight application integration. (We aren’t likely to see, say, a set of Evernote or TaskPaper actions.)

If you are uncomfortable with “just write this script”, please do feel free to ask if there’s a non-scripting approach that’s easier to manage, or if it’s possible to better “package” that script (some easy variables to fill out rather than editing a complex script).

2 Likes

I'm a scripter and I agree with you. When building a KM macro, or suggesting solutions to others, I first try to design it using native KM Actions (non-script actions). In fact, I have lots of KM macros that I could have done in script, but I found it easier/quicker to do just using KM Actions.

Interest in scripting here in the KM forum seems to go in cycles. We seem to currently be in a period of high interest, but I suspect that will die down after a while.

1 Like

Astute observation from @Rather.

True, some things only scripting can do, so a big "thank you" to scripters here.

But plenty of scripts, I think, "KM alone could do that, or most of that, and a lot easier to modify and maintain, too."

"To a hammer, every problem looks like a nail."

Here’s some reasons for script postings:

  1. To do something that KM can’t.
  2. KM could do it, but it would be either cumbersome, slow, or both.
  • For an example of slow, try iterating through all the lines of a text file (after reading the file into a KM variable, of course). Watch how slow it gets as the number of lines in the file increases.

IMO, almost all of the scripts posted in this forum are because of those reasons.

Or at least the belief that those reasons are true - I know that for me, I’ve sometimes posted a script answer because I didn’t know KM could do it, and do it just fine. But that’s not the case most of the time.

1 Like

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