Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a command that exists that can simulate keypresses? I want to pipe some data to it to make it type into a GUI program for me.

share|improve this question
up vote 6 down vote accepted

Yes, it is xdotool.

To simulate a key press, use:

xdotool key <key>

For example, to simulate pressing F2:

xdotool key F2

To simulate pressing crtl + c:

xdotool key ctrl+c

To simulate pressing ctrl + c and then a Backspace:

xdotool key ctrl+c BackSpace

Check man xdotool to get more idea.

You might need to install the xdotool package first to use xdotool command.

share|improve this answer
    
Sweet! I'm assuming people use this for remote connections? – SpecialBomb yesterday
    
@SpecialBomb Depends..i use it sometimes to simulate a key inside a script.. – heemayl yesterday
    
Well, thanks! I'm going to use it specifically to make my own remote connection thing. – SpecialBomb yesterday
    
I used it so that my computer wouldn't sleep while I was watching movies. – Liam yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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