Copy Function Timeouts Without Updating System Clipboard

Hi all,
I'm using the "Copy" function to copy some texts into the system clipboard. And then I want to append the text with text from another variable. The final product is saved back to the system clipboard ready to be pasted.

However, the macro keeps getting time-out at the copy function without updating system clipboard.
Any help is greatly appreciated. I'm using KM 9.

Copy Citation.kmmacros (5.4 KB)

This is very unusual. You must be copying something very large, or maybe from one of the MS Office apps.

IAC, you can change the timeout on the Copy action using its Gear menu:

image

Another option is to use Type a Keystroke of ⌘C with a Pause Until the clipboard has changed:

Pause Until Clipboard Changes (Action Group)

Group.kmactions (1.6 KB)

NOTE: This download is for Actions. Before you import, select the action in your macro after which you wish to insert this action.

I've tried changing time-out time, using your macro, but the clipboard still doesn't update. Could this be a problem with KM 9?

Aaron

Possibly, but let's try some more troubleshooting first so we're not just stabbing in the dark.

  • Do you have any clipboard managers running?
  • What content are you trying to copy?
  • What application does the content come from?
  • Do copy actions work on text that you select in something like Notes.app?
  • Have you taken a look at any logs to try and narrow things down?

Edit: Woops, I've just gone to the next tab I opened and seen that there might indeed be an issue with KM 9. See this thread - Workaround to Clipboard

1 Like

It is indeed a documented issue in KM 9. I was the one who initiated the thread.

Howard

Are you aware if a solution has been found for the issue? I'm having the same problem.

Pretty sure the next version of KM fixed it. 9.0.1 or something like that. Maybe check the release notes for 9.0.1 through 9.0.5?

I am on KM 9.0.5 (on Mojave 10.14.6), and I just ran into this same problem. Having a simple "copy" action in a macro timed out. (Specifics: I am tried to create a macro that copies text I selected in a metadata field in Adobe Lightroom.)

Copying plain text should be very fast. I do that often with KM, and it works well.
Does a manual copy (with the Edit > Copy, or ⌘C) work OK? If so, then likely there is something wrong with your Macro design.

Please upload your macro so we can inspect and test.

Also, Please read:
Tip: How Do I Get The Best Answer in the Shortest Time?

Yes, the regular system copy (with the Edit > Copy, or ⌘C) works fine. I created the simplest macro — just the Copy action, and tried it in a number of applications (including "Stickies"), and get the same timeout error each time. Here's the macro and the error:

timeout error

copy test Macro (v9.0.5)

copy test.kmmacros (1.5 KB)

What this means is that Keyboard Maestro simulated the Command-C key, and then the clipboard did not change.

If this happens in multiple applications, then perhaps Keyboard Maestro cannot simulate any keys, which would point to an accessibility problem likely resolved by toggling the accessibility permissions in the System Preferences as described at: Accessibility Permission Problem assistance.

Thanks for the suggestion. I am on Mojave (10.14.6), so I followed the instructions on the help page you referenced:

  • quit both Keyboard Maestro and Keyboard Maestro Engine
  • open System Preferences > Security & Privacy > Privacy pane
  • select Accessibility
  • delete entries for both Keyboard Maestro and Keyboard Maestro Engine
  • launch KM and ensure that the Accessibility for both KM and KME are ticked

security-accessibilty

Alas, the problem remains: the Copy action results in a timeout, when accessed anywhere (Finder, Stickies, TextEdit, etc.).

However, the Paste action works as expected.

I'm experiencing the same thing.

Hello,

Here is how I fixed the issue:
2021-03-17_12-13-55

Without the step that executes pbpaste and stores it in clipboard, no matter what I did, Copy did not work in the multiple applications that I tried (TextEdit, BBEdit, Excel, Notes).

I had been struggling with this issue of Copy (either the Copy action or by simulating Command-C key) not working for a couple of hours since today morning. The macro in question was last used 3 weeks ago, so I am not sure what happened during this time to cause this. I am on Catalina (10.15.7) with KM Version 9.2.

Initially, I thought that this might be due to an update I recently installed in MS Excel so tried using the apple script posted here: https://forum.keyboardmaestro.com/t/system-clipboard-not-getting-replaced/15188/9 to no avail. However, this was a red herring as I soon discovered that Copy (function or simulated keystroke) did not work in other applications as well.

I had followed the steps suggested for fixing Accessibility issues (TIP: Resolving Catalina/Mojave Accessibility/Security Permissions Issues), but they did not help. However, I soon discovered that simulating keystrokes was definitely working since I was able to get KM to simulate typing characters inside the problematic applications. Even for Excel, on simulating Command-C, the selection would change to a dotted box to prove that Command-C had indeed been successfully simulated.

Adding delays after the Command-C did not help.

Also tried killing pboard process to make sure this was not a case of the clipboard process having issues. Restarted MacOS just to tick off that old chestnut.

Hope this helps!

@JMichaelTX : My apologies for bringing this to your attention, but do you think that this might be worth adding as a workaround to the official documentation or as a note to the wiki?

I have used KM Copy Action with all of those and it works well.
Running Keyboard Maestro 9.2 on macOS 10.14.6 (Mojave).

If it is not working for you, that means that something is interfering with KM on your Mac.
Please read Troubleshooting -- KM Wiki.

Hey @azorpheunt,

This is basically impossible – so why is the impossible happening on your system? These kinds of things don't occur in a vacuum.

A) Do not simulate Cmd-C unless it's the only option available. There are too many things that can go wrong with simulated keystrokes. Use the Copy action or the Select or Show a Menu Item action to select the menu item Edit › Copy.

B) Bring up the Clipboard History Switcher and see what's in the History. Copy 3-4 things to it in the normal fashion, and make sure it's working correctly.

C) Do you have any other apps or utilities that use or might interfere with the clipboard?

D) Do you have any other apps or utilities that use or might interfere with the Cmd-C keystroke?

E) Does the problem occur when you boot your system in safe-mode?

F) If you create a clean new user and install only Keyboard Maestro, does the problem still occur?

-Chris

1 Like

Thank you very much for your wisdom @JMichaelTX and @ccstone

I tried the Troubleshooting instructions, and found things in KM that I never knew existed (which I guess is a testament to how well KM works as I've never had to debug an issue with a macro before). The Help Wizard did not reveal anything wrong with the Macro (which is a test macro with a step to copy something in different ways and a subsequent step to display the system clipboard).

The Clipboard History Switcher was much more interesting. I discovered that I could not activate the history switcher at all and then from another thread (Activate Clipboard History Switcher : Long delay) there was advice to do this :

defaults write com.stairways.keyboardmaestro.engine MaxClipboardHistory -int 20

And then everything started working. This still leaves the question of 'why now / what changed to cause this' unanswered, but I am happy to have things working now without hacks.

I have never used KM as a Clipboard manager before today, so am not sure what effect the above command had to fix the issue.

I just want to clarify that this is the desired, and expected behavior.
The KM Copy Action attempts to copy the selected object.
If that Action times-out, that means that either there was NO selection, OR, the selection was so large that it could not be copied within the timeout of the Copy Action.

This should be a rare event. However sometimes the User has NOT selected anything.
Thus, instead of terminating the macro (the default behavior), you can check the success of the prior action, and if it fails, then take some specific action.

In one of my Macros, if the Copy Action fails, then I select the text from the current insertion point to the end of the line, and then copy that.

HTH.

Apparently at some time either you or some macro you ran set the clipboard history to zero, and that fouls things up more than meets the eye.

I suggest you rerun your defaults command and set the history to at least 100. I have mine set to 500.

If you haven't used a clipboard-history utility on the Mac before, you've missed out on very useful functionality.

I use LaunchBar as my daily driver, Keyboard Maestro as backup and for more literal searching, and Paste (at need) for syncing between my devices.

-Chris

Thank you @ccstone

If you haven't used a clipboard-history utility on the Mac before, you've missed out on very useful functionality.

I totally agree with the usefulness of a clipboard manager. I do not use KM's clipboard manager since I prefer 'CopyQ' (open source, cross-platform) to reduce the jarring context switch between Windows and Mac when I am forced to use the former.

If I were to use Windows only, I would prefer 'Ditto' since its performance is much better than CopyQ (for instance when searching for regex).

If you've used CopyQ, I would be very interested to know how it compares to KM's clipboard manager.

Thank you!

2 Likes