Clipboard copy/paste problem

I'm making a macro to create a link between items in two OmniOutliner documents. The manual procedure is to:

  1. select text in Doc. A,
  2. copy as link (which puts the item's URL on the system clipboard),
  3. go to the other document and issue the Create Link command,
  4. in the resulting pop-up, enter the link title,
  5. tab to the URL field,
  6. paste the URL from the system clipboard.

Screen Shot 2020-10-27 at 08.39.04

With my macro, I'm trying to copy both the link and the selected text, then go to the other document and paste both in the above popup.

Thus, copy as link, then store that link on Clipboard_A, then while the text is still selected, copy that text to the system clipboard. Then go to the other document, open the Create Link popup, paste the text as the display title, tab to the URL field, then paste the URL I've stored on Clipboard_A.

But it's not working. It seems my Copy System Clipboard to Named Clipboard "Clipboard_A" isn't working. It just contains whatever was last in the system clipboard. I feel like I'm close, but not quite there yet! Thanks for your ideas...

There may be a much better way to do this, but here's what I have now:

There is no reason to use Named Clipboards for plain text. You need them only for rich text, images, and objects.

So, you could use this untested set KM Actions:

  1. Copy
  2. Set Variable Local__LinkText to System Clipboard
  3. Select Menu "Copy as Link"
  4. Set Variable Local__LinkURL to System Clipboard
  5. Go to Previous Window
  6. Pause 0.1 sec (adjust as needed)
  7. Create Link
  8. Pause 0.1 sec (adjust as needed)
  9. Insert Text by Pasting action using %Variable%Local__LinkText%
  10. Tab
  11. Insert Text by Pasting action using %Variable%Local__LinkURL%

Let us know if this works for you.

That worked very well!

At first, it didn’t work when running, but did work when stepping through with the debugger, so I figured it needed pauses in places besides the ones you suggested.

Ultimately I found it didn’t need the pauses you suggested in steps 6 and 8, but for some reason it did need them after steps 2 and 3. Maybe just quirks of OmniOutliner.

Thanks for your help! This will save a lot of time and mouse-clicking.