Add a setting in KM to not fill clipboard with pasted text for `Insert text by pasting` action

I use Insert text by pasting action a lot as it is the fastest way to insert text I need on the screen. It has however a very annoying issue that it fills my clipboard with the pasted content which I literally never want. I can get around this by clearing the clipboard after the action every time I use it (very annoying).

Or I can use Insert text by typing action which doesn't have this problem but it unfortunately has an even bigger problem of it being much slower than Insert text by pasting. :disappointed:

@peternlewis Would it be possible to either make Insert text by typing as fast as Insert text by pasting (instant). Or have a global setting or something that would not fill user's clipboard with pasted text on Insert text by pasting action.

Thanks.

If you use MACRO: [KMFAM] Favorite Actions and Macros by @DanThomas, you can easily workaround this inconvience. Just create a Favorite Action that is both the Insert Text by Pasting AND Delete Current Clipboard.

I make great use of Dan's KMFAM system, and it works very well.

1 Like

Hey Nikita,

That's impossible.

Insert text by typing simulates the keyboard, and the macOS limits the speed of entry.

Are you talking about doing this manually? Or with Keyboard Maestro?

(See @JMichaelTX's answer to your post.)

-Chris

1 Like

As @ccstone says - I cannot make Insert Text by Typing any faster - it operates by simulating the keys necessary to do the typing in sequence, and the application must process them in sequence, and that limits the speed at which the operation can happen. It varies from application to application, but in general it would be less that 100 characters per second, and generally quite a lot less.

Also, Insert Text by Pasting can only work by setting the System Clipboard and then pasting (simulating a ⌘V). There are no other practical ways to do this (there are other ways in limited circumstances, using either AppleScript or the accessibility API, but neither work reliably in general).

So the only remaining option is to use the Delete Current Clipboard action after the Insert Text by Pasting action. However because the ⌘V is simulated as keystroke, and because that goes in to the event queue, and the target application may take an arbitrarily long time to process it, there is no way to know how quickly you can delete the clipboard after the Insert Text by Pasting action. If you delete it too quickly, then you will end up pasting the previous clipboard instead, because the clipboard would already be deleted by the time the target application gets around to processing the ⌘V. But if you wait too long, then you may set the clipboard to something else in the mean time, and that would then be deleted, potentially leading to lost information.

1 Like

I was thinking of having it as a flag setting within KM or something. But the approach of @JMichaelTX with defining a favorite action to use to paste text is good too.

My suggestion is for the usual abbreviation that you want to expand, use 3 actions instead of just 1 (#2):

  1. Set Variable "originalClipboard" to "%SystemClipboard%"
  2. Insert text by pasting (Default Command)
  3. Set SystemClipboard to Text "%originalClipboard%"

Hi @royce, and welcome to the KM forum.

Thanks for your suggestion. However you should know that it will only work if the original clipboard was only plain text. KM Variables can only store PLAIN text.

But you could use your basic logic, except use a KM Named Clipboard, which can and does store everyone that is on the System Clipboard.
So it would be:

  1. Copy "System Clipboard" to Named Clipboard "Original Clipboard"
  2. Insert Text by Pasting
  3. Copy Named Clipboard "Original Clipboard" to "System Clipboard"

See Copy Clipboard to Clipboard action.