System Clipboard Not Getting Replaced

Probably a rudimentary question...

I have this macro that does two RegEx search + replace actions to modify the clipboard.

With this Alert displaying the System Clipboard, everything looks good, but when I paste, I get the original copied text.

What am i doing wrong?

The first action does NOT wait for the copy to be completed.
So, you have to make sure the Clipboard has changed before you move on.
See

In which application?

Some applications, particularly cross platform apps, cache the clipboard, and then do not notice clipboard changes when Keyboard Maestro sets the clipboard (because the application is not expecting the clipboard to change).

Some options to force the application into updating its clipboard cache include:

  • Simulate a click in the menu bar.
  • Switch out and back to the application.

I'm copying from OmniFocus and pasting into various text editors, so maybe FoldingText, TaskPaper, or Drafts... Is there a way to force any app to update the clipboard cache?

As Peter said:

I tried both "pause until clipboard has changed" and "click in menubar" with no success. Not sure what I'm doing wrong here

You only need one set of "pause until clipboard has changed" actions around the initial copy, and you need to set the CBSeedBefore variable to CLIPBOARDSEED() (not CBCLIPBOARDSEED(), which is what you currently have) instead of 1 before the copy.

image

When inserting functions like CLIPBOARDSEED(), I recommend taking advantage of KM's various Insert menus to ensure you have the correct syntax:

Or even better, insert them by name with F, which lets you search for relevant terms like "clipboard":

Hope it is ok to revive this old topic, as I am having the same problem of "System Clipboard not getting replaced", and this topic is right on. Seems correct to keep them together.

I understand that LibreOffice (a cross platform MSO style office suite app like OpenOffice.org OOO ) is apparently caching the clipboard itself, and that is why my paste (sometimes) contains the previous clipboard, instead of what I have just set the clipboard to. After reading this thread I tried adding a menu bar click immediately before the paste, but that is not solving the problem.

When I tried switching out & back of the LO app - that sometimes did not get back to the correct app before pasting or "insert text by typing" & thus caused amazing & unexpected problems! OMG! Ha ha ha ha. Such a mess! However that switching concept is good, because when I manually switch apps & switch back, it always pastes the intended data.

Q: How else can I switch apps & back more reliably than the obvious "Activate Last App" then "Activate next app"? Or any method to force LO to replace/update it's clipboard from the system clipboard. I'm open for any ideas.

I use LibreOffice Writer text docs & LibreOffice Calc spreadsheets all day. With varied success on these Paste macros & various Set System Clipboard functions.
I feel so close to a reliable resolution, but def not there yet, and would really appreciate a leg up here.

THANKS!
Dave

IBDL Notes & Web view Macro (v9.0.6)

IBDL Notes & Web view.kmmacros (4.8 KB)

Hey Dave,

Try using this AppleScript to switch apps. It bumps out to the SystemUIServer and then back to the app that was previously frontmost.

You can adjust the timing by changing the value for delay (in seconds).

This will be less obtrusive than switching to a normal application (if it works).

-Chris


Execute an AppleScript.kmactions (1.3 KB)

image

Thanks Chris, that works fine to refresh the system clipboard in LibreOffice.
Much appreciated.
Dave

1 Like