How to compare two named clipboards?

i love and use the KM everyday but now, i have a problem, because i need a function.

How can I compare two named Clipboards, if they are identic ?

In my case it is not so important, what the content in the Clipboards is. In my function, i cut content in two separate clipboards on two different times, and then, i will check are the two Clipboards identic ?).
I need only a check: “Is the ClipBoard#1 identic with the Clipboard#2” --> Yes/No ?

or wonderful would be the follow check: ‘exist a identic Clipboard at Cliboard#1?’. --> Yes, the Output is the name of the Clipboard.

I hope, you can help me.

Kind Regards

Are you sure you need to use Named Clipboards (KM Wiki)?

If you are only storing plain text, then it is better to use Variables (KM Wiki).

Then, a comparison is easy, using the If Then Else action (KM Wiki).

You can copy the currently selected text to a KM Variable by using these actions:

Thank you, but i didn’t use plain Text, i use images.

  • I have a Image/Picture open on the Screen.
  • I make a ‘Crop Image’ (with exact Screenposition) to NamedClipboard#1 and a second ‘Crop Image’ from another Screenposition to NamedClipboard#2 and then, i will check, are the booth Clipboards (the CropImages) identic ?

OK, sorry for the misdirection.

AFAIK, KM cannot compare images or Named Clipboards. If there is a way, I’m sure someone will jump in here and correct me.

Until/if they do, you will probably need to save each image to a file, and then do a image file comparison using 3rd party tools, run from a Shell Script.

Good luck, and please do let us know if you find a solution.

Cropped images from the screen will almost never be identical. If they have any text in them, they will almost certainly not be identical.

Keyboard Maestro does not export any functionality to compare images I’m afraid.

@Christian, given @peternlewis’ response, looks like you will need to use 3rd party tools.

  • Try an Internet search of “mac compare image files”
  • Try a Forum search of “#macro screenshot” to find KM Macros that help you with making/managing screenshots

@Tom is a frequent forum member who is well versed in images and screenshots. Maybe he will pop in here with some suggestions. :wink:

ImageMagick has (quite) some nifty ways to compare images. For example this…

compare -metric AE <imgage1.png> <image2.png> null:

…will output the exact number of different pixels. So you can use the result to determine if the images are different enough – or identical, of course. You can also add a fuzz factor with -fuzz n% that will help to ignore minor differences.

It offers many variations on this, e.g. limiting the diff to one color channel or looking for matching subimages, etc.

Read this and that to learn more.


thank you to all. I know and have many workaround’s and they works still fine.
I just wanted to go a step further and realize the function in KM directly.
Thank you !