Empty the clipboard as keystrokes with AutoHotKey (Windows)

This is an AutoHotKey script for pasting the clipboard contents by simulating hardware keystrokes. It also fixes for stuck keys such as control and shift keys after the shortcut runs which are useful when pasting into a KVM, VMware console, RDP or Citrix session where latency is high or clipboard support doesn’t exist.

It is activated with <ctrl>+<alt>+<shift>+V

#NoEnv

;ctrl alt shift v
^+!+v::
   KeyWait Control ; Citrix fix for random stuck keys
   KeyWait Shift
   SetKeyDelay, 30, 20 
   SendRaw % RegExReplace(Clipboard, "\r\n?|\n\r?", "`n")

return

Empty the clipboard as keystrokes (Linux X11)

There is no AutoHotkey for Linux, however that is not needed, if you want to type the contents of the keyborad out the the currenly active window, you can create a keyboard shortcut (at least in KDE)

This shortcut will empty the clipboard contents as simulated keystrokes.

It also ensures that enter key is transmitted as a CRLF instead of just a LF without the fix here, when pasting into a Windows endpoint you will not get any enter CRLF and everything will be on one line.

sh -c 'sleep 0.5; xdotool type -- "$(xclip -o -selection clipboard | tr \\n \\r | sed s/\\r*\$//)"'

There is no delay between keystokes, with this appraoch if you want you can sleeping between every character. Delay was originally important to me when I used to connect to cable laying ships to manage the onboard systems which were on very slow satellite connections.

Wayland (Plasma 6)

The command is slightly different when using Wayland and Plasma 6:

sh -c 'sleep 0.5; ydotool type -- "$(wl-paste -n | tr \\n \\r | sed s/\\r*\$//)"'

Comments

comments powered by Disqus