Keyboard Maestro Logo

Clipboard Managers and Keyboard Maestro

On the Mac Geek Gab, Dave Hamilton has been singing the virtues of clipboard managers. These are tools that give you a clipboard history beyond the single most recent thing you’ve copied. I’ve been intrigued, as I love anything that increases productivity. I recently discovered that there’s a clipboard manager built into Keyboard Maestro, which I already own.

For the past month or so, I’ve tried to figure out what utility the clipboard manager inside Keyboard Maestro will give me and, to be honest, it hadn’t seemed to solve any problem I have. To use the Keyboard Maestro clipboard manager, you copy a bunch of things one after another and then go to where you want to paste, and then open up Keyboard Maestro and copy each thing out of it to paste. At least that’s how I thought it worked, and was confused on how this saved any time or keystrokes.

While at Macstock I cornered Dave during one of the breaks to ask him about this. I made it very clear that I believed him that clipboard managers were useful but that I just couldn’t find a use case for me where they made any sense. I wasn’t resistant to learning how to use them or embracing them but rather I wanted to get it through my head how they could be useful to me.

Dave explained that one of the main reasons to use a clipboard manager is to keep your brain in one context. If you need to copy, switch to another app, paste, switch back, do some more stuff, copy, switch back, during all those switches your brain gets easily distracted and you are likely to start doing something unrelated or at the very least lose focus on the task at hand. Ok, I’ll buy that.

I brought up Keyboard Maestro and showed him how I was trying to use it and how it seemed a waste if after switching to where I wanted to paste, I had to copy again from Keyboard Maestro. He showed me that you don’t have to copy and paste from Keyboard Maestro, but rather just arrow down to the thing you want and hit enter. Ok, that’s a little better, but still seems like a lot of overhead to me.

I showed him that there are numbers next to each copied item and that it seemed reasonable to me that when I invoke Keyboard Maestro when I’m ready to start pasting, I should be able to use the numbers to just grab the one I want instead of arrowing down a bunch and then hitting enter. However, hitting those numbers just jumps to some random thing I copied, not to the one corresponding to the number I’ve typed.

I’ll jump ahead in the story and explain that I wrote to the developers and got a response that the numbers are just for reference and are not intended to allow you to jump to that specific item. I didn’t understand what that “for reference” part meant until later in the story.

Keyboard Maestro clipboard history switcher
Keyboard Maestro’s Clipboard History Switcher

Around this time, Brett Terpstra, one of the most fascinating people I’ve met at Macstock or in life in general, came wandering over to see what we were up to. He and Dave started talking about how clipboard managers are at the core of existence in an existential world and how could I not grok that yet? It didn’t really help much because I already believed but I couldn’t see yet why this was so.

I decided to show them a place where I believed a clipboard manager could really help me but I needed to see why the way I was using it was so wasteful of steps. The use case I have is putting in chapter marks for the podcast. Let me explain what I have to do for each one.

I put the cursor in the recording where I want the chapter. Then I hit command-shift-enter to create the chapter mark. This adds a row up above the recording area where I have to enter the chapter info. There are three fields. I have to enter the chapter mark name, the URL title, and the URL. Not all chapters need all three fields, but my chapters usually take you right to the blog post corresponding to the current recording so I do need all three.

Hindenburg chapter marks
Hindenburg Chapter Marks

To execute this without a clipboard manager is really tedious because I have to copy the title of the post from my blogging tool MarsEdit, command-tab over to Hindenburg, click on the field twice to get it to highlight, paste it into that field, and then tab to paste to the second title field, then command-tab back to MarsEdit, right click to copy the URL, then command-tab back to Hindenburg – it all gets very tedious!

I showed this to Dave and demonstrated how it didn’t really help me to use a clipboard manager because Hindenburg loses focus as soon as you click away. He made a really good point here, that it’s not that clipboard managers aren’t useful, it’s that Hindenburg is not using the official Apple APIs that would keep focus in the first place.

At this point, Dave and Brett and I sort of came up with the solution collaboratively. Here we were talking about using Keyboard Maestro as a clipboard manager, but Keyboard Maestro is actually an automation tool. What if we could use Keyboard Maestro’s automation talents in conjunction with its clipboard manager to solve the entire problem?

Brett in his talk later in the day explained that he can brainstorm anything so this was clearly his special talent.

Dave has done a lot of automation with Keyboard Maestro and I’ve done a tiny bit. I told him that I have found Keyboard Maestro’s automations to be very fragile. They’ll work once or twice but something changes and they fail. Undaunted we marched ahead.

Hindenburg chapter mark macro
Keyboard Maestro Macro for Hindenburg Chapters

Here are the basics of what we created together. We decided that I would copy the URL first, then the title, so the most recent item in the clipboard history would be the title. Then we executed the following steps:

  • Type the return keystroke first, which selects the name of the chapter mark ready to be changed
  • Paste the most recent item
  • Tab to the URL title filed
  • Paste again (which is still the most recent item)
  • Tab to the URL field
  • For the tricky bit – set the system clipboard to past clipboard 1
  • Paste

That system clipboard part was the bit I’d have never figured out on my own. The clipboard manager inside Keyboard Maestro has the most recent item in position 0, the one before it in position 1, etc. So this command is saying to take the item one back in the clipboard manager and move it into the main system clipboard. That puts our URL into the “normal” system clipboard so we can paste it.

Remember those numbers next to the past history items in the clipboard manager in Keyboard Maestro that they said were “just for reference”? Now we know what they meant – the number I just used to move something from the past clipboard to the system clipboard is indicated by that little number.

After we created our 8-line macro and did a bit of fussing around, we finally got it to work. We had a huge celebration. The next day I decided to practice using it so that I could get some muscle memory started. And guess what? It failed. I can’t say I was surprised, because that’s what has happened to every Keyboard Maestro automation I’ve written to date. But I certainly was disappointed. The specific failure was the URL was being pasted into the URL title field as well as it’s own field.

I started searching for help online. The documentation is all in a wiki and it’s far from complete. The command I was working with was merely listed but not fully explained. In the developer’s Q&A section though, he said,

Just watch out for timing issues whenever you are reordering the clipboard – setting the clipboard is a synchronous action, whereas Paste (via Command-V) is a queued action, so it is not hard for them to get out of sync.

I suddenly understood the problem. Bart’s goal in Programming By Stealth hasn’t been to teach us HTML or CSS or JavaScript or any of the other tools. His goal has been to teach us to program. He wants us to learn how the specific languages works so that we learn about the structure and concepts of programming.

In a few recent episodes of Programming By Stealth, Bart taught us about AJAX calls to servers and how synchronization is an issue. The problem with AJAX calls is that the answers you get back may not be in the order of the requests you made. As soon as I saw the note from the dev of Keyboard Maestro, it clicked in my brain that this was the same problem as with AJAX.

In watching David Sparks’ Keyboard Maestro Field Guide, I remembered him say that he often had to put pauses into this code. But, that same week, I heard Marco Arment say on the Accidental Tech Podcast that if you were putting pauses in your code, you were doing it wrong. I assumed that maybe David just wasn’t using Keyboard Maestro properly.

While there are elegant methods to get around the problem of synchronous server calls in AJAX (they call them promises), Keyboard Maestro has no such methods, so I figured I’d try a pause just like David recommended.  And adding the pause before moving the clipboard contents around worked like a champ. Even better, it worked the second and third and fourth times I tested it!

I’m delighted that I now have a keystroke I can use to eliminate this annoying copy/tab/paste/tab problem from my workflow. I suspect it will take a while to get good at using it but I’m motivated because it bugs me so much.

What hasn’t happened yet is me falling in love with the concept of a clipboard manager. Dave talked about our conversation on them during a recent Mac Geek Gab, and Larry Lusch heard it and wrote to me suggesting a clipboard manager called Copy’em Paste from apprywhere.com/…. Larry swears by it and says that he’s tried them all. It’s $15 in the Mac App Store so I’ve had my finger hovering over the buy button for a week now.

I think I’ll just take Larry’s advice and buy it since he’s so passionate about it and because it has a beautiful interface. Heck, the numbers next to the copied items actually DO allow you to paste! Maybe I’ll come to love clipboard managers too. I’ll report back either way.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top