Issues with Copying

Hi there,

I have a problem with copying the highlighted text for this macro. It works half the time. Usually when I don't use it for a while and then call it, it pastes No Text in Clipboard instead of the word it was supposed to copy.

I have tried the Copy action, Copy to Named Clipboard and Cmd+C Keystroke.

Has anyone encountered a similar issue? Thanks!

Dictionary Lookup Lingea Macro (v10.2)

Dictionary Lookup Lingea.kmmacros (9.3 KB)

I rely on the Copy action a lot but when it doesn't deliver the bacon, it's invariably because there the Copy option is not active in the Edit menu. So I wrap the Copy in a test (If Menu Condition Copy is Enabled sort of thing) to see what's going on.

You shouldn't need those Pauses or a named clipboard for this, either.

1 Like

Instead of a static pause, try:

Set Local__CurrentClipboard to calculation CLIPBOARDSEED()
Copy
Pause until Local__CurrentClipboard ≠ CLIPBOARDSEED()

1 Like

Hi, @Anaxis. I don't remember all of the circumstances, but I've had some occasional problems with the Copy action. If I'm reading the wiki properly, one should not need a Pause or Pause Until when using this action. (By default, the Timeout is set to 10 Seconds.)

With that said, I've always found this approach to be fast and robust.

Download: Copy and Wait (up to 1 second) for the Clipboard to Update.kmmacros (25 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.4 (22F66)
  • Keyboard Maestro v10.2


Maybe @peternlewis will weight in and shed some light on this issue.

1 Like

That is pretty much exactly what the Copy action does.

Sounds to me like the target application is misbehaving.

You could do something like:

Set Clipboard to Text “KMNONEKM”
Copy
Pause Until System Clipboard does not contain the text “KMNONEKM”

Thank you, @peternlewis! Since that's the case, by default I'll start using this snippet:

Keyboard Maestro Export

When copying text, I'll change the Copy action Timeout and related settings as follows:


Maybe I had a misbehaving application as well and the different behavior I saw with Type a Keystroke ⌘C vs Copy was coincidental.


For anyone following this thread...

When your macro changes the System Clipboard, you might want to consider restoring it at the end of your macro. You can use the following snippet and adjust the repeat times depending on the number of times the macro updated the clipboard (or exclude the repeat if it was only once).

Keyboard Maestro Export

1 Like

I wonder if there's a way to auto-assess the number of clipboard changes that occur during a macro run and then use that to delete past clipboard seeds...?

Simpler is probably just:

  • Copy System Clipboard to Named Clipboard “Temporary”
  • Do stuff
  • Copy Named Clipboard “Temporary” to System Clipboard

Most of the time you aren't overly worried about the clipboard history, only what is currently in the System Clipboard.

2 Likes

Thanks, @peternlewis.

Seems to me that one would need to be careful to avoid collisions of Named Clipboards if taking that approach. Since it appears that the Named Clipboard name cannot be changed dynamically, here's one possible approach.

Download: Restore Clipboard using a Named Clipboard.kmmacros (27 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.4 (22F66)
  • Keyboard Maestro v10.2