Daring Fireball: Keyboard Maestro Hack of the Week: Don’t Paste Images

The awesome John Gruber has long been a fan of Keyboard Maestro, while I've been a fan of his work for a similarly long time.

His recent article of a Keyboard Maestro macro he created is at:

It's a great example of how Keyboard Maestro can be used to customise applications to behave more like you want.

3 Likes

I recognize this:

I’ve spent 10× more time writing about this macro here than I did creating it.

Great guy. Pointed me to ModernCSV, a great app.

Oops, my bad: it was Justin Pot.

I’ve spent 10× more time writing about this macro here than I did creating it.

Even though it's making the opposite point, I was reminded of this quote:

I have a well-deserved reputation for being something of a gadget freak, and am rarely happier than when spending an entire day programming my computer to perform automatically a task that would otherwise take me a good ten seconds to do by hand.
-Douglas Adams

Douglas Adams would've been utterly smitten with Keyboard Maestro.

5 Likes

This is actually what I do all the time. My argument is that instead of using a checklist to deliver my work and perform the many steps manually, I can better invest a lot of time to automate the process and be sure that I haven’t forgotten anything.

1 Like

From the article:

When I first tried this, many years ago, I was half worried that it would trigger an infinite loop, where the simulated keystroke from the Keyboard Maestro macro would re-trigger the macro. I was wrong to worry — Keyboard Maestro is too clever for that.

It might just be worth a general reminder that the Wiki page for Type Keystroke action cautions that “You should not use this action to simulate a keystroke that is the same as an active Hot Key Trigger”. Even though KM is clever (that is to say that Peter is thorough!), I would opt for “best practice”.

I have not used MarsEdit in a long time and I do not currently have it installed, but I would fully expect KM's Paste action to work. As an undoubtedly unnecessary alternative to that, a Select or Show a Menu Item action would be able to select "Paste" if it exists as a menu item, which it surely would.

None of that is meant to detract from the article, and obviously ⌘-V calling ⌘-V worked out fine in the example. I just prefer to be cautious and go by the book (wiki), especially when alternative actions can be used just as easily.

I have found that there is a lot of scope for macros, triggered by ⌘-C and ⌘-V, that augment a copying or pasting process. Actions can be added to transform data after it is copied and before it is pasted, and of course by using macro groups, the behaviour can be different per application.

For example, in a macro group that is only active for Music.app, I have a macro, triggered by ⌘-C, that uses the Copy action (obviously!) and then a Search and Replace action that removes “Visit ” from “Visit http…”. I quite often need to copy the URL for a Bandcamp release, and Bandcamp thinks I need to be told to “Visit ” it. The macro means that I do not have to manually delete “Visit…” for the URL to work in a Web browser.

Another such action (with some just slightly more complicated regex) in the same macro transforms the contents of any copied track details, ready for pasting.

2 Likes

Douglas Adams was one of my very first customers. Not for Keyboard Maestro, but for Anarchie back in 1994. I had a lovely email exchange with him which I treasure.

I wouldn't normally divulge a customer details, but I feel he wouldn't mind the mention here, and we've been without him for over twenty years so I think it's ok to make an exception here.

9 Likes

Keyboard Maestro goes out of its way to ensure this is as safe as possible and works as expected, but because of the system event queue it can never be a a guarantee that it will work as expected.

So it's best to avoid it if possible, but it will work as expected generally.

2 Likes

Douglas Adams was one of my very first customers. Not for Keyboard Maestro, but for Anarchie back in 1994.

Context for those of us born later: Interarchy - Wikipedia

1 Like

My first ftp client!

1 Like