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 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
This is the AHK v1 script:
#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
This is the AHK v2 script:
The good thing about V2 is that it works even when Citrix is in full screen mode.
#Warn All, Off
^+!v::
{
KeyWait("Control") ; Citrix fix for random stuck keys
KeyWait("Shift")
SetKeyDelay(30, 20)
SendEvent "{Raw}" A_Clipboard
}
```none
# 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 keyboard out the the currently 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.
```none
sh -c 'sleep 0.5; xdotool type -- "$(xclip -o -selection clipboard | tr \\n \\r | sed s/\\r*\$//)"'
There is no delay between keystrokes, with this approach if you want you can sleep between every character. Delay was originally important to me when I used to connect to cable laying ships to manage the on-board systems which were on very slow satellite connections.
Wayland (Plasma 6)¶
The command is slightly different when using Wayland and Plasma 6:
sleep 0.5; ydotool type -e 0 "$(wl-paste -t text/plain -p -n)"
Configure this as a keyboard shortcut under:
System Settings -> Keyboard -> Shortcuts -> Add New -> Command or Script…
Comments
comments powered by Disqus