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:   @CB Paste From Clipboard History

~~~ VER: 3.0    2017-03-21 ~~~

####DOWNLOAD:
@CB Paste From Clipboard History.kmmacros (2.0 KB)


For example, this Clipboard history:

will result in this being pasted:

2nd Item in Clipboard History

Questions?

1 Like

It works well when works alone. but in anki app. it just cannot work. The prompt is that delete past clipboard failed
https://apps.ankiweb.net/

Is there some reason this would not work:

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

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!