A simple script to simulate keypresses to type copied text, in places where pasting is not enabled and don't have access to install new apps
(Remote or local virtual desktops, various online forms, ssh connection through old terminal emulators etc)
😅 A lot of people are using this, but couldn't get anyone to star this repo...
$wshell = New-Object -ComObject wscript.shell;$txt='';foreach ($element in $(Get-Clipboard)){$element=$element -replace '[+^%~(){}]','{$0}';$element= -join($element,'{ENTER}');echo $element;$txt = -join($txt,$element);};sleep 4; $wshell.SendKeys($txt);
run this in powershell, and within 4 sec, place cursor at where you want to type all out
prettyfiled code
$wshell = New-Object -ComObject wscript.shell;
$txt='';
foreach ($element in $(Get-Clipboard)){
$element=$element -replace '[+^%~(){}]','{$0}';
$element= -join($element,'{ENTER}');
echo $element;
$txt = -join($txt,$element);
};
sleep 4; $wshell.SendKeys($txt);
start the ydotoold
service as demon (this is for security reason on wayland, )
systemctl start ydotoold; // for socket errors try YDOTOOL_SOCKET='/tmp/.ydotool_socket' ydotool type 'hi'
To type from clipboard
sleep 3;ydotool type $(wl-paste)
To type from file
sleep 4;ydotool type -f <filename>
sleep 4; xdotool type "$(xclip -o -selection clipboard)"
For apple users, here is a AppleScript with works the same
delay 4
tell application "System Events" to keystroke (the clipboard as text)
https://stackoverflow.com/a/63468725/15070114
inspired by -
https://christitus.com/clickpaste
wayland toggleable script
change
!#
lines to#!/bin/bash
in case you are not using nixos