1

Once in a while I come across annoying web sites, which think they know security and won't allow me to paste password from password manager. I want a tool which allows me to take clipboard text and paste it into a web site. I know how to obtain contents of the clipboard (xclip), but how could I take that text and paste it in form of keystrokes?...

1

Here is a simpler version I found elsewhere...

sh -c 'sleep 0.5; xdotool type "$(xclip -o -selection clipboard)"'

The sleep command appears to give X enough time to switch things around, without it, it loses the first 5 or 6 characters on my system. You might be able to lower it on some systems.

0

I did some digging, and it seems that pasting could be achieved using xdotool

Here is a script I wrote, which could then be bound to a keystroke:

#!/bin/bash

XCLIP=$(which xclip)
if [ "$XCLIP" == "" ]; then
    echo "Need to install xclip"
    exit 1
fi

XDOTOOL=$(which xdotool)
if [ "$XDOTOOL" == "" ]; then
    echo "Need to install xdotool"
    exit 1
fi

TEXT=$($XCLIP -out)

if [ "$TEXT" == "" ]; then
    exit;
fi

ACTIVEWIN=$($XDOTOOL getactivewindow)
if [ "$ACTIVEWIN" == "" ]; then
    exit;
fi

$XDOTOOL type --window $ACTIVEWIN "$TEXT"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.