I'd like to have a macro triggered when both of the following are true...
The system clipboard has changed.
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.
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.
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!
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.
TIL the hard way that the "System Clipboard Changed" trigger is not invoked when com.stairways.keyboardmaestro.engine MaxClipboardHistory had been set to 0 to disable pasteboard history.
Leaving this here, in case someone else in the future struggles with that trigger.
Thanks at @noisneil. As a layman I'd say that this costs an awful lot of resources. But I guess that Peter has arranged things in such a way that the impact on my system will be minimal?
Want to use this to have a short URL created automatically via TinyURL whenever the clipboard contains the string https://www.dropbox.com/scl/fi/, which I retrieve via:
It's just a content check whenever the clipboard changes, which can be further restricted by current application or other conditions. Sure, if for some reason the clipboard changed 100 times per second, it might be an issue, but that seems unlikely.
Regarding Dropbox links, you could do it all in one:
I've added this to the auto-copy macro too. If you hit โงโC while in your Dropbox folder, it will copy the link and notify accordingly. Worth noting that you need to be on macOS Sequoia (or later) for it to work, as it uses the new context menu shortcut, โโต.
Auto-Shorten Copied Dropbox Links.kmmacros (24.8 KB)
BTW: While trying to create a better regular expression, I managed to make Keyboard Maestro not responding anymore (there obviously was an error in my expression). Even the Kill all macro didn't work anymore.