Skip to content

Paste by Typing

Below are some methods to have the content inside the clipboard typed into the current cursor position across some different operative systems.

The reason for this is that there are some situations where traditional "pasting" wouldn't work. Such as when we connect to an RDP server with clipboard sharing disabled, when we use a Virtual Machine that doesn't have guest features installed to allow it, when inputting some fields that explicitly capture the shortcut to disallow pasting, etc.

Windows ​

There's two alternative approaches.

An easy and convenient way would be using AutoHotKey to have a simple script that defines a key shortcut (eg. Ctrl-Shift-V) to type the contents of the clipboard. AutoHotKey also supports compiling its scripts into standalone executables, so that would be a portable way to do it.

AutoHotKey
; It "types" the contents of the clipboard.
^+v::Send {Raw}%Clipboard%

However, some secure environments might not allow you to run AutoHotKey scripts. If this is the case, and if you do have access to running Powershell scripts, then the following powershell would show the content of the clipboard in a terminal window, wait for a delay (so you can position the cursor where you need it) and type it.

powershell
# It "types" the contents of the clipboard.
# Useful when pasting doesn't work (eg. RDP or VM not sharing clipboard)

$content = Get-Clipboard
Write-Output "____ CONTENT TO PASTE ____" $content "__________________________"
Write-Output "  Press Ctrl+C to abort"

timeout 7
if ($?) {
  $content.ToCharArray() | ForEach-Object {[System.Windows.Forms.SendKeys]::SendWait($_)}
}

Linux ​

For Linux we will have to make use of different tools depending on whether we are using X or Wayland as our display server.

For X, we'll need xclip to read the clipboard and xdotool to do the typing.

bash
xclip -selection clipboard -out | tr \\n \\r | xdotool selectwindow windowfocus type --clearmodifiers --delay 25 --window %@ --file -

For wayland, we'll use wl-clipboard to read the clipboard and wtype to do the typing.

bash
wl-paste -n | tr \\n \\r | wtype -

Personal page