Best way to check if clipboard changed?

I am making a macro where I need to check if clipboard has changed after I press cmd + c.

How can I do it?

I am thinking of something like this but not sure if that is the best way and I am still not sure how to reference variables. :expressionless:

Is this a good way to do it?

Thank you for any help.

I used to use a similar method, until I discovered:
function:CLIPBOARDSEED [Keyboard Maestro Wiki]

I now think this is the best method to use.

I just posted an example macro showing how to use this:

1 Like

To not forget the obvious: there is also a macro trigger for clipboard changes:

Good point, Tom. But that is NOT a choice you can use within a macro to determine if the user has made a selection before the COPY command.

Yes, Michael, that’s clear. But from the OP it’s not entirely clear to me, wether the test has to be done within a macro, or if a standalone test serves as well β€”or better.

WTF? How am I just hearing about this? I've read lots of discussions on the subject of how to know when a COPY has finished, and I've never seen this mentioned.

So this appears to work:

Unbelievable.

And thanks, BTW. :slight_smile:

2 Likes

To paraphrase an old, sexist saying:

So many women, er a, KM features, so little time till I check out. :wink:

Sorry ladies, no offense intended, but feel free to insult me. That was an expression from my much, much younger days, which no longer applies. :smiling_imp:

1 Like

how do I do this in if statement?

I want to do if/else based of if clipboard has changed

Hi, @nikivi. You might find this thread helpful: Get Selected Text, Otherwise Clipboard

Not in an if statement. Do this instead:

image

but with this I can't do branching or I must be missing something

Hi, @nikivi. How about this?

Download: Set Value to π™Žπ™šπ™‘π™šπ™˜π™©π™žπ™€π™£- otherwise 𝙣π™ͺ𝙑𝙑.kmmacros (10 KB)

2 Likes

wow that's perfect
thanks a lot :heart:

1 Like

Glad this helped. Bear in mind, that it's possible that you could get some false positives. For example, if you have a file selected in the Finder, then local_Text will be set to the filename. That could be considered a bug or feature; it depends on your requirements.

1 Like

This is unnecessary in recent versions - Keyboard Maestro’s Copy action will wait for the clipboard seed to change itself.

@_jims shows how to use this to determine if the action succeeded in a timely manner.

3 Likes

But I don't get how to use:

To do if/else

It has Pause until but that's not what I want.

I don't see how I can use below in if statement:

It turns out that you don't need to use "CLIPBOARDSEED()" with a copy statement. If the "Copy" succeeds, then something was copied. If it fails, then nothing was copied.

how can i catch error on copy?

do I check for local_clipboard_seed here?