How to compare clipboard records

Hello!

I want to compare two last clipboards, for example the first one is 10 and the second one is 20.

If both clipboards are the same then do nothing, if they different then receive i notification.

Compare how? You can compare them numerically, or you can compare the plain text of them. Comparing two clipboards for identicalness would be a challenge since clipboards can have a lot of different flavors and what constitutes "the same" would be impossible for some flavors.

But this would be a starting point:

The first test is the same as:

But it is more obviously consistent using text conditions for both.

I have done it like this:

It works even if the clipboards have different formatting.

1 Like

You may want to change the "matches" to "is" for a direct comparison.
Using "matches" invokes the KM RegEx engine, in which case "10" would match "1", since "1" is part of "10".

Note that the below IF/THEN indicates true when it should be false.

1 Like

Could someone please take a look at my macro?
I can't understand why it doesn't work

I am trying to compare two Named Clipboards:

Named Clipboard Test1 = 1
Named Clipboard Test2 = 1

But by some reason they doesn't match.Compare Number.kmmacros (2.3 KB)

It works if i compare system clipboard and pastclipboard

You might try changing "matches" to "is" for a direct comparison. Using "matches" invokes the KM RegEx engine to make the comparison.

Having said that, why are you using Named Clipboards to compare plain text? IMO, it is better to use KM Variables for plain text. The only benefit Named Clipboards offer is the storage of images and styled text.

1 Like

Solved