Simulating key press using bash

13,881

Xdotool (no idea what happened to the webpage, here is its source) is great for that:

xdotool key k

And with gedit:

gedit & sleep 2; xdotool key k; 
Share:
13,881
abilash
Author by

abilash

Updated on June 25, 2022

Comments

  • abilash
    abilash almost 2 years

    I try to run gedit from terminal and type some text in a file opened there, but have no success. I try to use gedit; sleep 2; xte -x display 'key k'; command but this one run gedit only(without typing the k char). Can some one chip in me?

  • abilash
    abilash over 11 years
    I've tried it, but during compiling there is an error appeared. fatal error: X11/Xlib.h: No such file or directory. I use Ubuntu 12.04 32 bits system. How can I fix it?
  • BeniBela
    BeniBela over 11 years
    Perhaps you need libx11-dev? But somewhere there are binaries (perhaps even in the Ubuntu repository)
  • abilash
    abilash over 11 years
    I install it, but i have the same problem for this util. When I use gedit; sleep 2; xdotool key k; command line it runs gedit only(without typing symbols), and only after closing gedit it types k char in terminal. But how can I force this util to type chars into gedit opened file???
  • BeniBela
    BeniBela over 11 years
    perhaps i should have actually read your question... See the edit