Cancel macro if activated by any other macro?

I have a macro that runs on clipboard change that I use a ton (the decrufting macro I posted the other day). Because it runs on clipboard change, lots of other macros trigger it—anything that touches copy/paste. That's not a huge problem, because the macro is really good at quitting very quickly when non-relevant information is found, but it's not really elegant.

What I'd really like to do is add a conditional at the start of the macro that cancels it if it was activated because another macro caused the pasteboard change. Basically, if any other macro is active when the clipboard changes, the decrufting macro just shouldn't run.

Is such a thing possible?

thanks;
-rob.

Could you set it to run only when a named clipboard is changed that way the system clipboard doesn't affect it? This would mean that it would need to be triggered manually, but if you're already using it as part of a larger workflow that you trigger yourself, then you could just add an extra action to copy the contents to that named clipboard which would then trigger it. Just spitballing here since I don't use any macros that are triggered with clipboard changes... I'll keep trying to think of something else though.

EDIT: Another idea...you could have it run only with a specific parameter...and all the other macros that are currently triggering it shouldn’t unless they also supply that specific parameter...again, just spitballing. I really don't know what I'm talking about but maybe there's a good idea in there somewhere :sweat_smile:

Thanks for the suggestions ... unfortunately, the one that runs all the time (the URL decrufter) has to run on main clipboard change, because I want it acting whenever I copy a URL. The way it works now, it launches on clipboard change, and very quickly determines if what's on the clipboard is applicable or not—it quits in a few hundredths of a second if not.

But some of my other macros make repeated use of the clipboard, which means it's triggered repeatedly. The perfectionist in me is annoyed by this, despite the fact that it takes almost no computational time. I was just hoping there was some sort of function or token that I wasn't aware of that would reveal if a macro was activated due to the actions of another macro versus the actions of the user.

But it appears it's not worth the effort I'd have to expend to work around it—thanks for the help, though!

regards;
-rob.

Could you make a simple macro that copies your current selection to specific clipboard, and have your decrufter run only when that clipboard changes? You could set up a hotkey trigger like ⇧⌘C or so me other random combination you don't currently use and just use that when you're copying a URL... your normal ⌘C would still work like normal, copying to system clipboard which should prevent your decrufter macro from running.

I'm mostly decrufting hyperlinks in email messages, so I have to use the contextual menu. In the past I've written macros to open the contextual menu and copy the link, so I could assign a keyboard shortcut, but they're always kind of janky (and you have to move the mouse to reach the link anyway, so it's a simple right-click from there).

I think I'll just leave it the way it is now, and for my one really complex other macro, which has five or six copy and paste actions, I can just add a disable/enable pair to turn the decrufter off then on.

Thanks for the suggestions, though!

-rob.

1 Like