How can I get the second to last item in clipboard?

For example,I pressed COMMAD+C for 2 times,and there are two items in clipboard。then I want to paste it to

but I do not know how to get the last but one item in KM?

If I understand correctly, you are copying two items, and pasting them into separate fields.

You can use actions like:

This will paste the last item, delete it, and the next paste will be the last but one (second to last) item.

If this is something you do often, it's nice to have a macro with a typed string trigger like:

Make sure to create a second one that types the clipboard, because some forms do not allow pasting for security reasons.

do not work
this is my clipboard

and this is my macro

and this is what i get

what is wrong?
it seems wrong in here, and how to solve it?

Add another Pause after the Delete past clipboard 0 action.

You are deleting Past Clipboard 1 when you should be deleting Past Clipboard 0

#2 -- 2017-03-21 9:19 PM CT

  • I have completely replaced my previous macro with the below macro, which is NON-destructive.
  • The means that it does NOT delete any of your Clipboard History.
  • Revised to reflect the method used by @peternlewis below.

##Macro Library   @CB Paste From Clipboard History

<a class="attachment" href="/uploads/default/original/2X/8/8acf494d240eff4282c9c2bc1230835e8169ee69.kmmacros">@CB Paste From Clipboard History.kmmacros</a> (2.0 KB)


<img src="/uploads/default/original/2X/4/4fbd5d1fd6a3ff8b0fe9eaf68b231d5b03da8ffb.png" width="512" height="501"> 

For example, this Clipboard history:

<img src="/uploads/default/original/2X/a/a8cb3a82a6ac395bc7ef48f82907b770a3366e79.png" width="494" height="151">

will result in this being pasted:

>2nd Item in Clipboard History

1 Like

It works well when works alone. but in anki app. it just cannot work. The prompt is that delete past clipboard failed

Is there some reason this would not work:

Well, probably with a Type Keystroke Tab to switch fields I guess.

1 Like

finally this works, I have to say that the clipboard of KM is rather complicated! It is clipboard history is something strange. KM's clipboard history is different from that of other apps.

What you are doing there is not pasting the last item and the past but one. You are pasting the current clipboard and the second last clipboard, and in the process adding a new one.

“Insert text by pasting” is functionally equivalent to “set clipboard to text; paste”.

So your very first action gets the current clipboard, and sets it (as text only) to the clipboard, and then pastes.

And by that point you now have moved around the clipboard history and are likely to confuse yourself.

What I showed would work better, although by the sounds of it you want Past Clipboard 2, not 1.

But better is probably to read all the entries you want in to variables, and then paste them all in from variables, that way the clipboard history moving around afterwards will not cause problems.

1 Like

anyway,Thanks a lot!