Trigger macro when system clipboard changes *and* new clipboard item contains a specific string?

I'd like to have a macro triggered when both of the following are true...

  1. The system clipboard has changed.

  2. The new system clipboard item contains a specific string. (For purposes of this post, let's say "xyz".)

Is there a way to do this?

I suppose one approach would be to use the "clipboard changed" trigger, and then have the first action somehow check if the current system clipboard item contains the string in question. It it does, then the macro can proceed. If it doesn't, then the macro would be cancelled.

But perhaps folks can suggest a better approach?

Yes, this is pretty simple. Here's an example that notifies you when the clipboard contains the designated string:

Clipboard Check.kmmacros (21 KB)

Macro screenshot

1 Like

Thanks! This makes a lot of sense. With that said, is there no way to do this where the macro doesn't get triggered at all if the new clipboard item doesn't contain the string? I guess there's just not a trigger that would accommodate for this?

A macro is either triggered or it isn't. I wouldn't worry about resource usage for something as simple as this, because if the If/Else condition isn't satisfied, then nothing beyond it will happen.

Additionally, you can restrict this macro by placing it in a group that is only available for specific applications, so that will cut down on the number of runs. This obviously depends on whether you want it to be available for a specific application or globally.

More generally, it's always a good idea to give broader context, in order to avoid an XY problem.

Depending on your ultimate aim, this may or may not be a good/efficient route towards it.

1 Like

This reason probably sounds silly, but honestly, I just get distracted when the KM menu bar icon starts circling. So I just wanted to try to minimize that here. But if not possible, not the end of the world!

That's totally possible:

Clipboard Check.kmmacros (21 KB)

Macro screenshot

You won't find the Don't Rotate Status Menu action in the Keyboard Maestro actions list, as it's something Peter (the developer) posted to the forum. If you want to reuse it for other macros, save it as a favourite.

1 Like

Oh wow. I had no idea about this. Thank you!