Copy-paste macro does not work as usual

@DanThomas, you don't need the CLIPBOARDSEED() test with the "Copy" action. It is built into that action.

From action:Copy [Keyboard Maestro Wiki]

The Cut and Copy actions wait until the clipboard changes before proceeding.

One other point. With the "Pause Until" it will wait a long time, and then fail if the user has not selected anything prior to the "Copy". The default Timeout of the Pause Until Action is huge: 99 Hours.

Instead of issuing Cmd-X, you could use the code I posted above, and change the “Copy” action to a “Cut” action.

But if you have a half-second pause, then this may not be your issue, because a half-second usually long enough. However, give it a shot and see.

As it is, the issue is not related to timing. I’ve tried the “NULL” solution from above, but it still does not reliably paste the clipboard content.

Mostly the macro will just fill the clipboard and paste its contents fine. But then it works 6 times, does not work once, then works again. It’s just unreliable.

Sometimes it takes 3 or 4 seconds for the clipboard to fill, sometimes it does not get filled with text at all. The process can be watched in the clipboard history switcher.

The weird thing is that as long as I do the cut-paste by hand on the keyboard, it works every single time. The issue only arises when Keyboard Maestro does the cut-paste (Cmd-X, Cmd-V). Granted, Keyboard Maestro may not cause this, because I only did the cut-paste process about 30-40 times with both Keyboard Maestro and the keyboard.

Is there a way to trigger the keypresses differently (say with a script) that adds nothing from Keyboard Maestro to the keypress (https://wiki.keyboardmaestro.com/action/Copy)?

Perhaps you missed the suggestion by @DanThomas.

Replace the CMD-X and CMD-V Type Keystroke Actions with "CUT" and "PASTE" Actions respectively. Also, if you have any CMD-C, replace with "COPY".

1 Like

Understood. These would offer an alternative if timing were an issue. But timing is not an issue.

To restate the problem:
The clipboard does sometimes not fill when Keyboard Maestro cuts text to the clipboard. The issue does not arise when doing the cutting by hand (on the keyboard).

It has no effect whether I use Cut, Cmd-X or an AppleScript that simulates Cmd-X.

takes text from a Fusion VM and pastes it into applications depending on user choice

It may depend on the particular application where the text is copied from.

For example, @jehrler recently discovered an intermittent copy/paste issue that only happens with iWork apps and only when copied via KM.

The problem only arose over time. When I left the client, there was no unusual behavior.

Maybe she has installed some background applications that are interfering somehow? (E.g. a clipboard manager, or even things that at first glance seem completely unrelated.)

Try to boot the client’s Mac in safe mode, launch KM Engine and see if the issue is still there.

What exactly happens when you use the KM Action "Cut"?

  1. Does the Action automatically cancel due to timeout?

  2. Does the Action continue, but nothing is on the Clipboard?

Try this simple Macro:

and let us know the results.

Hi Michael

The action times out in those cases where the clipboard does not fill.
When I repeat the action, the clipboard gets pasted twice.

As I said, the issue does not happen when cutting and pasting by hand.

Do you know another way to transfer selected text from one program to another?
Getting desperate here.

Thanks and regards

How are you doing this by hand? Keyboard shortcuts? If so, which?
Could you please make a short video showing:

  1. The workflow when done manually, by hand.
  2. The workflow using the test Macro I posted above.

Unfortunately, using an old version of Keyboard Maestro, and old version of macOS, Fusion VM, and who knows what inside that and then getting inconsistent results makes it extremely difficult to make any kind of suggestion as to how to improve the situation.

You can use the Type a Keystroke to type the Command-C or Command-X. Or you could use AppleScript to simulate the keystrokes. Whether that gets you any more reliable results is dubious, since all the Copy action does is type a Command-C and wait for the clipboard to change.

As for your questions:

I can't make a video right now, as I am not that often at the client's. I am not sure what it would accomplish as you would see me doing the same thing the macro does.

In the meanwhile the IT provider of the client has upgraded to Sierra and Keyboard Maestro is now on the latest version. The problem is still there.

How are you doing this by hand? Keyboard shortcuts? If so, which?

Cmd-A, Cmd-X, Cmd-Tab, Cmd-V in this sequence.

Hard to say. I can't see anything unusual. There is no clipboard monitoring app besides Keyboard Maestro AFAICS. There's a bunch of medical software that is standard with my other client's.

[quote="Peter's mail, as I wrote him directly"]
So does it work if you simulate a Command-X keystroke in Keyboard Maestro or AppleScript?[/quote]
No, according to the client AppleScript works worse. If anybody cares the apple script is

tell application "System Events" to keystroke "x" using command down"

What next

Is there any Keyboard Maestro log I can look at that would give some information on what's happening?

For now, I will create a new Keyboard Maestro file and see if that does something. I haven't tried that. Maybe the upgrading has damaged something.
I will make an inventory of running processes and see if Safe Mode works better the next time I am there.

That’s vague.

And it’s always “hard to say” – until you have isolated it.

For example, for some time I noticed an inexplicable GUI glitch in BBEdit. I tried a couple of things, without success. One day I booted in safe mode and noticed that the glitch did not happen. Well, this taught me that the responsible thing likely was some other process/application, rather than the system or the app itself.

It took me days, but this morning I solved the puzzle and it turned out, the culprit was not one of my suspects, nor one of Barebone’s suspects; it was an app that at first glance seemed completely unrelated.

It's up to you, of course.
In my experience actually watching "over the user's shoulder" (video in this case) will often provide insightful info to me that the user was not aware of.

The KM "Copy" and "Paste" actions are very robust. I use them all the time without any issues.
Most likely, there is something outside of KM, or improper use of KM, that is causing the issue you are seeing.

Good luck!

If the sequence:

tell application "System Events" to keystroke "a" using command down"

Pause

tell application "System Events" to keystroke "x" using command down"

does not do the same thing as you manually typing Command-A, Command-X then I’m afraid it is highly unlikely there is anything I can do, and there will not be anything I can log to assist with the problem, since the events will be being generated and then the target application will be misbehaving, but the misbehaving is happening on the other side of the event queue within the target application.

Thanks for all your suggestions. They give me hope that something can be done.

Well, I’ll have to keep calm and carry on: go and isolate it. Nothing else to do here. Will report back with my findings.

FWIW, I just found that the Cut command always times out, because the Mac clipboard actually only gets filled when Fusion loses focus. The Cut command was actually never active at the client’s because of some syncing issue (it basically overwrote my changes and the script with the Cmd-X - Cmd-V was still active).

I’m sure you’ve been back and forth over this a dozen times, but it seems to me that when I last used Fusion (many years ago), there were a couple of preference settings that might be relevant here — “clipboard sharing with the host system” type settings.

And/or, does your client use Unity? and do your other clients? That might be relevant, too.

Also, I’ve heard that re-installing VMWare Tools on the virtual machine can help with problems like this.

1 Like

Erik, thanks.

  1. Clipboard is being shared. Unchecking and rechecking the setting does not resolve the issue.
  2. No Unity in use anywhere, VMs run in a window, not full screen (Unity does not work for the kind of thing I’m doing in the VM)
  3. Vmware Tools reinstalled, at least once. Vmware also updated to the latest version (currently 8.5.3., the problem was there already with 8.5.2).

Vmware support also contacted, but they say that if copying by hand works, it’s not their problem. I don’t blame them. It’s likely not Keyboard Maestro either. It’s some other bloody thing I’ve overlooked.

Short update: I was not able to isolate the problem.
In Safe Boot VMware Fusion can’t be started. This article does not work.

There are 6 applications running at all times, all of which are essential. Turning them off did not improve things anyway.

Rebuilding the Mac is most likely the best option.

Thanks for your help.

If you are referring to this line…

All kernel extensions are loaded when Fusion is started. Fusion 4.x can be run in Safe Boot normally.

Yes, this may be no longer true for recent macOS versions. However, you can try to load Fusion’s kernel extensions manually with kextload. (Instructions I, instructions II, man page)

1 Like

FYI, the rebuilding of the Mac did the trick (mostly, see below).
The clipboard syncing now works reliably. Whatever caused the error is now gone.

One device key of a USB device stops working from time to time. I’ve show the client how to restart Keyboard Maestro to make it work again.