This is the macro I made to automatically copy. When I select texts, it will auto copy. But when it came to the image, I had to copy the image by right-clicking on it. so I use the system clipboard changes to trigger palette. this will result in an infinite loop, So how to avoid the infinite loop.
Hey there, one glaring issue is that you have a trigger for when the system clipboard changes... and the very first action is ⌘C to copy, which again changes the system clipboard, which is the trigger, which executes the macro again, and copies again, and triggers again and so forth.
Generally you do not want to use a copy action inside a macro that has this trigger because it will get stuck in an endless loop. I'll take a closer look at it tomorrow and see if I have any ideas for you.
You could maybe use an if action in conjunction with the %TriggerBase% token to copy only if the trigger that executed the macro is not a clipboard change. See the screenshot for what I'm referring to.
If action with %TriggerBase% token screenshot (click to expand/collapse)
ok thank you.
I neglected to set the conditions. I find the answer to my question by comparing my macros with yours.
I'll go read the wiki page again. Since English is not my first language, it may be difficult to read, but I will try to understand it.
The first thing to understand is that this isn't an "infinite loop". It looks like one, but what you were actually doing is repeatedly spawning new instances of the macro, one per clipboard change. That's why @tiffle's "Semaphore lock" works -- it says "if I am already running, do not create another instance of me". That's also why you have to wait until the macro completes before you can run it again.
I won't pretend to understand why you want to do what you are trying to do -- but, perhaps, another approach would be better?
It sounds like you either have:
The pointer over some already selected text or
The pointer over an image
...and you'd like to use a macro to copy either text or image then "do things". You can play on the fact that if no text is selected and you do ⌘C the clipboard doesn't change. But, rather than using a clipboard trigger, compare before and after CLIPBOARDSEED() values (that changes every time the clipboard changes).
If CLIPBOARDSEED() changes then you copied some selected text -- carry on. If it doesn't then you had no text selected, assume the pointer is over an image, do a "Copy Image", and carry on. Something like this (tested in Safari, change the trigger to suit):
Thank you for your reply.
I didn't quite understand it at first, but it wasn't until I downloaded the macro to test it that I found it worked well.
Thank you all for giving me different opinions, I can learn a lot