Clipboard. How to copy and paste multiple items in a specific order

I am trying to copy and paste three separate bits of information from a Wikipedia page by adding them to my system clipboard, so that I can copy them in a specific order in a basic spreadsheet lookalike interface on jetpunk.com.

If you do not know jetpunk.com, It is a quizz website where you can create quizzes (scooop!). One can do it by adding questions and theirs answers in a Google Sheets lookalike interface.

I saw @peternlewis answer on one related post saying variables would help. I thought too. But I now feel like what worked at 2PM is not working the same way at 6PM.

My problem is I do not understand why Keyboard Maestro is pasting what it is pasting in the order it is pasting the different clipboards.

Once all my three bits of information are copied to my clipboard, I set the cursor in one of the cell on the table on jetpunk. What I am trying to achieve is pasting, in the same cell, the content of "clipboard position 3", then "|", then the content of "clipboard position 2", then move to the cell on the left, then paste the content of "clipboard position 1".

What I don't understand is how can Keyboard Maestro paste a content that is not in one of my 5 last copied items...

I really fresh eyes on this. Feel free to ask any further information :grinning:

Below is the macro attached.

Names Surnames - Clipboard.kmmacros (6.9 KB)

Here's an alternate approach. You could keep copying multiple items to a global variable as a per-line like this:

Then you can do whatever you want with that list.

Thank you @noisneil. But how do I access each item of the list once copied as a variable?

One way is to convert the per-line list into an array, using a character that you know won't ever be part of the copied content as a custom delimiter. In this example, I've gone for $, because I'm all about dat money yo.

JetPunk Paste.kmmacros (21 KB)

Macro screenshot

As of KM 11 you can use a list like that as a KM array with custom delimiter of \n without any conversion:

"Support \ processing in variable token array item separators (eg %Variable%Lines[3]\n%)"

3 Likes

Look at me, all behind the times... Thanks @tiffle!

That simplifies things dramatically:

JetPunk Paste.kmmacros (21 KB)

Macro screenshot

1 Like

If you want to use variables, the way to do it is this:

  • Copy
  • Set variable "First" to text "%SystemClipboard%"
  • Tab (or whatever)
  • Copy
  • Set variable "Second" to text "%SystemClipboard%"
  • Tab (or whatever)
  • Copy
  • Set variable "Third" to text "%SystemClipboard%"

Then you can do whatever you want with the variables holding the contents in whatever order you might like, for example:

  • Set System Clipboard to Text "%Variable%Second%"
  • Paste
  • Tab (or whatever)
  • Set System Clipboard to Text "%Variable%First%"
  • Paste
  • Tab (or whatever)
  • Set System Clipboard to Text "%Variable%Third%"
  • Paste

(you can use Insert Text by Pasting action instead, of Set Clipboard & Paste, I was just using it this way for symmetry).

Unless I've misunderstood, I think the copying is manual; the pasting programmatic. If I'm right, I think creating a "copy stack", with a single hotkey makes a good deal more sense.

Perhaps I'm wrong and the copying is automated too?

Since you'll probably come across this in other macros you write, try opening the Clipboard Histroy Switcher then stepping through your original macro with the debugger ("Start Debugging" in the KM menubar icon, then run your macro) -- watch what happens to the order of the clipboard entries at each step.

But the short answer is that you don't need all those variables, you are going one entry too far back, and forgetting that when you set the clipboard to a past entry that entry is brought to the front of the queue and everything that was in front of it drop one place back.

So something like this:

Names Surnames - Clipboard.kmmacros (6.0 KB)

Image

1 Like

Thank you so much to anyone who took the time to post an answer to my question.

Many great ideas to create many more workflows :slight_smile:

And a special mention to @Nige_S who create the exact workflow I needed!