Paste from Clipboard History 1 and keep position?

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

That would be great! I see no advantage to the order changing after a paste.

1 Like

Don't necessarily want to change, always on the lookout for better ways to do things or to learn the power of the software better.

Pasting always has to set the system clipboard, that is how pasting works. The clipboard can be restored afterwards, but there are problems with that as described in wiki FAQ Why is the clipboard not restored after any clipboard action?.

Keyboard Maestro does not restore the system clipboard, not after this case, nor any other case where it pastes (eg with the Insert Text by Pasting action) because to do so invites problems. Either the clipboard is restored too quickly, and the original system clipboard is pasted instead of the desired one, or the clipboard is restored too slowly and something else has replaced it and is then overwritten.

Yes, it would be nice to be able to paste from something other than the system clipboard, but macOS does not support that concept.

2 Likes

Curious statement. If we can write a macro to do this, why can't you do it internal to KM? After all, you have direct control over everything except what is on the System clipboard.

1 Like

The point is, if you write it, then you take responsibility, and you have the option of controlling the delay.

If Keyboard Maestro does it, then when it fails, you have no recourse except to blame Keyboard Maestro for the system pasting the wrong thing.

Keyboard Maestro cannot do it reliably, so Keyboard Maestro does not do it.

1 Like

Perhaps so. But couldn't you at least do this:

Provide an option to paste from PastClipboard N, and then do NOT remove that clipboard from the history.

In that case, all the user would have to do is delete PastClipboard 0.

1 Like

That is doable, although it would break one of the rules about the clipboard history, that duplicate entries are removed. Admittedly, this rule has caused problems when trying to manipulate the clipboard on occasion, and it's not clear that it adds a whole lot of value (although clearly if you open the clipboard history and instead of seeing ten things you end up just seeing a pair of things multiple times that is a case where the rule adds value).

2 Likes

Hey Peter,

LaunchBar also removes duplicate entries from its clipboard history.

I find this annoying under several circumstances, and I think I would prefer to allow duplicates.

Perhaps with the ability to manually flush dupes at need, but I could live without it.

Usually I manage to muddle-through with both Keyboard Maestro's and LaunchBar's clipboard histories, but I still sometimes get bit in unexpected ways.

-Chris

1 Like

Right, but that is the exact point, and the user would be well aware of this when using this new paste action Paste from PastClipboard & Keep. Of course, with the use case we are discussing here, the duplicate would be quickly removed by the user's macro action Delete PastClipboard 0

Yes, I understand that. Internally, it would make no difference, I could keep references to the two clipboards.

But I do wonder whether it would end up with the history being cluttered up by many duplicates of the same thing. For example, I know when I am programming and moving things around, I will often copy the same variable name multiple times, and to have that scattered through the history would seem less than useful for the normal use of the clipboard history switcher for example.

I'm not sure how to best resolve these two conflicting use cases.