Is there an alternative to

xdotool type "a string"

It will be more useful if it is not an X11 app. Because X11 apps seem to be more vulnerable.

Note: I will not use it in a terminal window. So echo is not an alternative to that. echo does not type. It just prints something in terminal.


I've never even heard of xdotool before now, but according to it's gentoo package:

* x11-misc/xdotool
     Homepage:            http://www.semicomplete.com/projects/xdotool/
     Description:         Simulate keyboard input and mouse activity, move and resize windows

it sounds similar to what good old expect does, especially if you don't want X11:

* dev-tcltk/expect
     Homepage:            http://expect.nist.gov/
     Description:         tool for automating interactive applications

Edit: An example on how to use expect can (of course) be found on StackOverflow. Others should be available in expect's documentation and probably in the results of this search.

Wikipedia has some code examples, too. "typing" is done with the send command, while "reading" is done with expect. The manpage also hase some examples to get you started.

  • can you give me an example for type option for expect. – nano - merge me May 21 '14 at 19:30
  • edited my answer – Stefan Schmiedl May 21 '14 at 20:01
  • I could not find any command to type. add it if you know. – nano - merge me May 22 '14 at 13:19
  • that would be great if you add a command to type "hello" for me. the command send "hello" does not type. – nano - merge me May 22 '14 at 19:25
  • Since you were using xdotool, you are in a gui, but it would help to know what distro and desktop environments you are using. – Joe May 25 '14 at 19:21

If your desktop environment is Gnome or KDE (not sure if this will work anywhere else - and no idea about Gnome 3), then AutoKey is probably exactly what you're looking for (and a lot more!)

AutoKey does a lot of what xdotool does, but lets you configure everything in a GUI. It's a full keyboard/mouse event scripting system with phrases and scripting in Python3. Find info here with installation instructions here.

Normal output from AutoKey appears to your system as if you typed it on your keyboard, so no API or other changes to your applications are necessary.

In the simplest case, you define a phrase with an abbreviation and, optionally, a hotkey. When you type the abbreviation followed by a trigger character such as enter or tab (or press the hotkey), the abbreviation is replaced by the text of your phrase. There are a number of additional options controlling exactly how this works.

If you need to get more sophisticated, you can write an AutoKey script.

AutoKey scripts are written in Python3 which means that they are only limited by you coding ability. They can do almost anything (even invoke xdotool).

The current version is 0.95. If your package manager has an older version, you would be very much better off using the PPA or installing from source.

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.