How to avoid Infinite loop?

Just put a Semaphore Lock action with a short timeout at the start of your macro. This will prevent your macro from retriggering itself when it causes the clipboard to change.

Here's your original macro with the necessary modification:

auto copy v2.kmmacros (4.4 KB)

Keyboard Maestro Export

You should read the KM wiki page to understand why this happens/works. See https://wiki.keyboardmaestro.com/action/Semaphore_Lock

2 Likes