Paste from Clipboard History 1 and keep position?

As always after spending a minute to investigate, solution found.
Set variable to %PastClipboard%0%, paste the variable then delete past clipboard 0. nice

When I
"Set the system clipboard to Past Clipboard 1" and then paste.
It is pasting the 2nd clipboard, not the first.

The goal is to paste clipboard 1 and also have it stay in position 1.
Appreciate any help.
I did see a few posts but nothing addressed my issue.

This should work, although I have not tested it:

After the paste, do another:
"Set the system clipboard to Past Clipboard 1"

thanx man, I did see a post with that Set/Paste/Set but that does not work , it changes the order of the history.
I found the %PastClipboard%0% then paste then delete past clipboard 0, retains the past history order.

Paste Past Clipboard 01.kmmacros (1.8 KB)

I don't know what you did, but this definitely works for me:

Macro

image

Clipboard History BEFORE

image

Clipboard History AFTER

image

That does not work for me.
Mine pastes clipboard 2

Before

after

Well, it does work in the sense that the clipboard with "Two" was in position 2 both before and after the macro.

But I see the problem. You original clipboards were created by copying a rich text source. So, when KM converted them to plain text to paste, it now sees them as being different in content.

You method of Delete past clipboard 0 only works if the original items were rich text. When I try your method, I get:

image

So, the second item, which was "Four", has been lost.

Looks like this is a tricky problem. I don't see an obvious solution.

Ah, thank you for investigating, appreciated.
The following does solve the issue.

1 Like

Not for me.

You changed the clipboard being pasted from 1 to 0:
image

When I correct this to paste CB1, then that CB is lost, when all clipboards were plain text.

There seems to be something going on depending if it is rich text or not -
I just tested with 'plain text' and the result is different than with rich text.
Should they not respond the same way? rich or plain, that makes it difficult to create an across the board solution.

For Rich Text
Here are macros pasting clipboard history 1 thru 4 (individual macros - 4 of them)
the before and after history stay the same which is my goal

Global Macro Group Macros.kmmacros (6.7 KB)

Yep.

So, we have to test the contents of %PastClipboard%1% to see if it is rich text or not.

This macro seems to work with both rich text and plain text in the CB History. Test it to see if it works for you.

MACRO:Β Β Β Test Paste Past Clipboard

~~~ VER: 1.0Β Β Β Β 2018-08-11 ~~~

DOWNLOAD:

Test Paste Past Clipboard.kmmacros (3.6 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


image

This works for rich or plain text but, it is pasting clipboard 2 not 1 in both cases. And cannot set the first step to clipboard 0, probably with a variable it will work.
Ah- but a variable does not keep formatting.

And why when you paste a past clipboard history, does it change the order to the clipboard history? Nothing new has been copied. I would think it would only change when something was copied.
It only changes when a macro uses the action to paste a past clipboard.
If you use command v to paste something the history does not change.

There seems to be some confusion about which Past Clipboard you want to paste.

To be clear, the first clipboard shown in the Clipboard History is the System Clipboard, and is accessed by either:

  • %SystemClipboard%
  • %PastClipboard%0%

The PastClipboard # is one less than the order shown on the Clipboard History.

image

When referring to Past Clipboards, it is best to always refer to them by the %PastClipboard%#%, where 0 is the System Clipboard.

So, which Clipboard is it that you actually want to paste?
My above Macro will paste PastClipboard #1.

A simple Paste will paste the first Clipboard (the System Clipboard), and keep it as the first clipboard in the History.

oh boy, as always, thank you for your patience, expertise, and explanation.
I of course was using the numbers in the history switcher pane, NOT the past clipboard # as you have explained it.
I will work with this and hopefully come up with a solution that works for rtf and plain, probably the solution you provided earlier will be perfect, I'll have to keep in mind that the most recently copied data is 0, =ing the clipboard.

No, it does not work.
It works for past clipboard 1 but not 2 and higher.
I'd like to have a set of keys - 1 thru 10 (with whatever modifier)
that will paste either plain or rich text from past clipboards.

ie
β‡§βŒ˜1 will do a simple paste since that is the current system clipboard
β‡§βŒ˜2 will paste what is in the past clipboard #1 and not change the order regardless of rich or plain text
β‡§βŒ˜3 will paste what is in the past clipboard #2 and not change the order regardless of rich or plain text
β‡§βŒ˜4 will paste what is in the past clipboard #3 and not change the order regardless of rich or plain text
etc etc -

I think you are trying to use the Clipboard History in a way that was never intended, or thought of. It may be possible, but I think it would be a lot of work.

I think you would be better of with using Global Variables or a Dictionary with plain text data, and Named Clipboards for rich text/images/objects.

@JMichaelTX You are correct, my understanding of this tool is not good.
For my education, would you mind giving me an example of how you might use the Clipboard History Swither? I'm sure that would help me immensely.

What I have been using for quite awhile is a conflict palette for storing/recalling data with clipboards. I frequently have 4, 5 or more numbers/text that I want to recall in the near future but not always in a certain order or within a definite time frame. This has worked well for me. Just sharing. -
βŒƒKey Pad 1 is for storing - followed by any number 1-9 will store in the corresponding clipboard
βŒƒKey Pad 2 is for recalling - followed by any number 1-9 will recall from the corresponding clipboard

Clipboards` Macros.kmmacros (41 KB)

That looks like an excellent system. Since it has worked well for you, why do you want to change to using the Clipboard History?

As I see it, the Clipboard History Switcher is primarily used for:

You can then paste any previous system clipboard by triggering the Clipboard History Switcher macro. Clipboard History Switcher will present you with a window allowing you to select any of the past clipboard and paste them.

So I use it visually most of the time: (1) Display the Switcher; (2) Double-click on the Clipboard I want to paste.

However, I do use it in an automated way, like in this macro:
MACRO: Paste In Order Copied

I've not really used the Favorites or Search feature, but they might be of interest to you.

You can mark entries as favorites, in which case they will never be removed from the clipboard history. You can toggle a filter to show only the favorites in the search field (top right), or by option clicking on the favorites button.

You can use the search field to filter the clipboards.

Have just now carefully read through the Wiki on Clipboard History Switcher I realize that it probably has functions/features that I could use, but have not do so.

So maybe some experimentation is called for. :wink:

Wow, that is a lot of messages.

A couple things:

  • Set System Clipboard to past clipboard 1

is not the same as:

  • Set System Clipboard to plain text β€œ%PastClipboard%1”

In particular, the latter is likely to add an entry to the clipboard history, since the plain text clipboard is different to the original clipboard entry, which probably had some amount of styling or other information associated with it (unless it was created as a plain text clipboard with the same text by Keyboard Maestro).

So you really should just need to do this

  • Set System Clipboard to past clipboard 1
  • Paste
  • Set System Clipboard to past clipboard 1

There may be issues where that fails due to clipboard caching or the asynchronous nature of clipboard handling and keyboard event queues (the Command-V for the Paste), but it should work in general, and result in the clipboard history being unchanged from before the macro.

Peter, you changed two things between the statements, and never used the correct syntax for %PastClipboard%1%. So the intent of your statement is unclear.

Maybe you were using different Actions, but it is not clear.

I think we figured out that using past clipboard 1 would work, but what about using another past clipboard, say #3? Would that keep past clipboard 3 in the same order on the Clipboard history?

Just did this test. Neither Worked:

Test 1

image


Test 2

image


But perhaps you meant something else?

β€œSet System Clipboard to past clipboard 3” would take past clipboard 3 (ie the one that is fourth in the list of the clipboard history), and move it to the front of the clipboard history into the system clipboard.

So if you now want to reorder it so that it was back the way it was, you would have to repeat the action three more times.

  • Set System Clipboard to past clipboard 3
  • Set System Clipboard to past clipboard 3
  • Set System Clipboard to past clipboard 3

Which would rotate the four initial entries in the clipboard history around until they were back the way they started.

1 Like

A lot of work and complication just to maintain original clipboard order.
Would you entertain an enhancement request to Paste from Past Clipbboard # and make no changes to History?

1 Like