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

I have an application which is built using GTK+. The application has a very simple interface. When started, the same window always opens, with a few input controls.

We want to write a script to fill in text in a couple fields, check a check box, then click a button. Pretty simple, and would be easy to do if a command-line version of the app were available (but it isn't).

What's the best way to approach interacting with an X application programmatically?

share|improve this question
up vote 4 down vote accepted

Give xdotool a look. It's extremely powerful and should be able to do whatever you need.


share|improve this answer
i think the use of xdotool should only be considered in real emergency cases! Scripting something serious with xdotool is more a pain than a pleasure. Before you try xdotool ask the developer if the application has a dbus interface. That would make your plan much simpler. – user1146332 Jul 26 '13 at 14:20

xte, part of xautomation is another tool that you can use to generates fake X11 input using the XTest extension.

From the homepage:

Control X from the command line for scripts, and do "visual scraping" to find things on the screen. The control interface allows mouse movement, clicking, button up/down, key up/down, etc, and uses the XTest extension so you don't have the annoying problems that xse has when apps ignore sent events. The visgrep program find images inside of images and reports the coordinates, allowing progams to find buttons, etc, on the screen to click on.

share|improve this answer

If atk/at-spi is supported/enabled for your desktop , you might want to give dogtail a try:

"...Dogtail is a GUI test tool and automation framework written in Python. It uses Accessibility (A11Y1)) technologies to communicate with desktop applications. Dogtail scripts are written in Python and executed like any other Python program..."

(an old tutorial here, just to give you an idea of how this works)

share|improve this answer

Your Answer


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.