I now only make KM macros with chatGPT

My experience using chatGPT to make Keyboard Maestro macros over the past 5 months has completely changed how I use KM. I am neither a KM guru, programming expert or chatGPT lover -- in fact, I struggle using all these tools. But I know enough to be able to check what's going on, and importantly, chatGPT can also help me do that. The problems I have been able to solve recently using chatGPT has made Keyboard Maestro even more valuable to me -- and that's why I'm posting this -- maybe it will help others.

To illustrate, I'm providing 2 examples: one simple and one complex (at least to me).

For this first example I instructed chatGPT to make a .kmmacros file to replace spelled numbers with arabic numerals in selected text. After it finished, it gave me a link to download the .kmmacros file and this summary for how the macro operates:

It operates on selected text and converts examples such as:

* `twenty-three` β†’ `23`
* `one hundred and five` β†’ `105`
* `two thousand and six` β†’ `2,006`
* `three million two hundred thousand` β†’ `3,200,000`
* `three and five` β†’ `3 and 5`
* `minus twenty-five` β†’ `-25`

It deliberately leaves **ordinals** (`twenty-first`) and **decimals expressed with β€œpoint”** (`three point five`) unchanged.

Double-clicking on the .kmmacros file opened it in KM and after reviewing it I enabled it and tested. The macro failed, so I pasted the KM error message into chatGPT along with a description of exactly how I tested and it described the problem, fixed it and provided a new .kmmacros file to download. That one worked perfectly.

Simple example: Replace Spelled Numbers with Numerals
Replace Spelled Numbers with Numerals.kmmacros (35.7 KB)

In my experience, chatGPT tends to use Execute Script and Apple Script actions to do the heavy lifting. When I have specifically instructed it to use native KM actions wherever possible, it has sometimes asked me to provide a sample .kmmacros file with the desired type of KM actions. And I often will have it explain to me how both KM actions and particular parts of the scripts work. To me, that's really helpful for learning.

To explain my more complex example, here is the prompt it produces when I select 4 image/video files and trigger the macro:


The macro reduces all the image or video files to the new width and quality specified and optionally shows a report of how much space was saved for each file. Progress during long runs can be monitored by the name of the report .txt file which changes every minute showing how many MB have been processed. It also uses imageOptim to further reduce the image sizes.

reduce selected images or videos.kmmacros (31.5 KB)

This one required many iterations in order to correct errors in the .kmmacros files chatGPT produced and to add features that I wanted later. I also modify the macro myself, of course, when it's easy. Although it took a long time to make, it was simple because all I was doing was testing each chatGPT iteration and explaining what wasn't working. I can't imagine how long it would've taken me without chatGPT to make a macro with these features, if I could even do it.

I'm interested in what Keyboard Maestro experts out there will say about my experience -- I anticipate I'll be told to be very careful and check the code. Although I did so at first, I must admit to doing so less now that many months have passed with so many useful macros produced. I'm ready to be admonished.

3 Likes

Hardly an expert, so these opinions are worth what you're paying for them :wink:

  1. If a macro does what you want, does it matter how you made it or how it works?
  2. If using an LLM helps you make macros you couldn't (lack of knowledge) or wouldn't (lack of time) have made before -- brilliant!
  3. LLMs have been trained on a lot of shell script and JavaScript, some AppleScript, not a lot of KM-specific stuff and LLM-created macros will reflect that in both logic and "correctness"
  4. LLMs can produce working code/macros, but they rarely produce good code/macros. That doesn't really matter (see point 1) unless you also want efficiency -- obvious example of that is where the LLM includes and AppleScript or Swift script which would be fine for a single execution, then puts that inside a "For Each" Action so you get instantiation/compilation delays every... single.. time... you... loop...

IMO, the sweet spot is to use LLMs to fill in the gaps in your knowledge and save some time -- and use some of that saved time to increase your knowledge so you can improve your macros. A virtuous circle, and it'll get easier as you learn the foibles of your LLM. An example of that is with AppleScript -- being trained on many non-AS patterns, LLMs have a habit of forcing case on a string before doing a text comparison, not knowing that AS text comparisons are case-insensitive by default.

A more concrete example? In your second macro, the first Action after the initial comments sets a variable, Local_baseNames, to an empty string. But Local variables don't exist until they get set to a value! So you're wasting a millisecond creating a variable to delete it. Similarly with setting Local__NewWidth and Local__CRF to hard-coded values immediately before setting them via the "Prompt" -- why?

You'll see more of both of those in the future, so watch out for them. Every millisecond helps! :wink:

Thank you @Nige_S for the tips. I realize that LLM's don't have true intelligence, but I wonder if I explained details like you mentioned it would be able to learn that for the future?

I don't know for sure, but my guess is it would because I have told it my preference for how I want several things done and it seems to be remembering. For example, I have told it to always prefer the simplest possible solution, provide a lot of details about exactly what it did and to just give me the facts and don't waste words being nice to me.

I use the most advanced model that I can and keep notes on what I learn in my large "notes on keyboard maestro" Google doc

That's beyond me -- my main interaction with the various LLMs is sorting out the problems they've caused for other people!

If you haven't seen it already, have a read of the "A coding agent skill..." thread -- I'm sure you'll get some ideas from that.

Yes, that was interesting, but I think most there are above my Keyboard Maestro skill level. For example, I barely have a clue how to write bash or Apple scripts and so avoid them.

On the other hand, I really have made an effort to learn both so I do scroll through to see if it generally makes sense. Since chatGPT uses them so much, I ask questions about code within them that is mysterious to me.

Also, I tell chatGPT to make it maintainable by breaking scripts into smaller chunks with variables that I can display for debugging.

1 Like

The most optimistic construction that one can put on all the time that people are spending in this way is the Iain McGilchrist image of "The Master and his Emissary" – the thought that the properly human is the world of imagination and value – the rest can be delegated.

Master-slave relationships are, however, notoriously ambiguous and reversible – Roman literature in particular expresses deep unease about the dangers of this kind of relationship.


What is more, Master and Emissary competes poorly with a rival image – that of addictive goods, first distributed free, or at low cost, to establish dependency, before prices are ramped up to gouge.

B.A.T. dumping cart-loads of free cigarettes in East Asian villages before the second world war to establish profitable dependency, others dumping cart-loads of free brandy in Southern African villages, as a prelude to breaking up rural barter economies with a need for brandy-buying cash, to create a source of labour for mines. See Charles van Onselen – RANDLORDS AND ROTGUT, 1886-1903

If the startling scale of investment in LLMs is ever to break a return, or avoid breaking the markets, then prices will need, in time, to gouge very painfully, once dependence has set in.

If you do use these tools while they still don't break the bank, then use them to actively learn – not to sit losing your time, training their models, becoming dependent, in exchange for baubles and trinkets.

@ComplexPoint

I appreciate that you quoted my exact words, but the parts you omitted are a significant counterpoint to your post:

Although it took a long time to make, it was simple because all I was doing was testing each chatGPT iteration and explaining what wasn't working

In other words, the way I'm using chatGPT with Keyboard Maestro is so simple that it allows me to do more macros or more advanced macros than I would have done otherwise -- this preserves my energies for tasks that truly require my efforts.

On the other hand, I think your points are interesting and relevant to something I did recently: made a request to receive all my chatGPT posts. In one chat session it said it could organize all those to make an easily searchable archive -- that will be useful if I reach the point where a Declaration is needed:

"When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among..."

Note the founding fathers didn't say "another person"... how wise they were

Simple here means little cognitive effort ? And this is a good thing ?

I wish I could share your optimism :slight_smile:

The healthy market in gym memberships, and equipment, does suggests quite broad awareness of the lamentable costs of minimal physical effort.

But perhaps the costs of declining cognitive effort have yet to be fully noticed ?

AI’s impact on cognitive ability: MIT study reveals more troubling data β€” MIT Media Lab

Good luck !

More practically, I would suggest that this forum can understand you better, and give you faster and more solid solutions, than any model of language, however large.

To those who help you, you will have contributed a gym exercise.

They, in return, can do a better job, than any LLM, of helping you to learn and build your own capacity to flex such muscles, and solve such problems.

Again, you quote what I wrote, but I omit the key parts:

This is what tools have always done when used properly.

1 Like

And one of the things that tools have always done is, of course, to amputate the faculties that they extend.

My personal feeling is that the cost is greater when those faculties are cognitive.

But bottom line – this forum will reward your time more richly than interactions with an LLM which makes you wait, under-occupied, while it learns from you.

As much as I've gained and enjoyed most of my interactions in this forum, I can honestly say that I've learned at least 10 times more using ChatGPT.

As for the time spent, I have to wait much longer, even to the point of forgetting what I asked sometimes, when I post questions on this forum. And because I cannot instantly correct any misunderstanding like I can with ChatGPT, that waiting time is further amplified each time I have to interact with someone over and over again who has misunderstood.

By contrast with ChatGPT, every time I have to wait the short time that it takes to see a response I'm able to do other productive things and never forget what I asked because I get the answer so quickly.

Again, I want to emphasize that I really appreciate most of the interactions that I've had on this forum. But there have also been a lot that have been quite a waste of time. I don't think that's ever happened with ChatGPT regarding keyboard Maestro help.

I’m using Claude to aid in my creation of KM macros. Is AI making us stupid? I can’t answer for that, but I recall in the 1970s when people said cheap electronic calculators would make us all stupid. I don’t think it happened. AI is not my Lord and savior. It is just another tool in my toolbox.