Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

README.rdoc

– This file is part of Xdo. Copyright © 2009, 2010 Marvin Gülker

Initia in potestate nostra sunt, de eventu fortuna iudicat.

++

XDo

XDo is a library to simulate keyboard and mouse input and manipulating windows on the X server. It's wrapped around the command-line tools xdotool, xsel, xwininfo, eject and xkill, so you will need to have them installed if you want to use Xdo (even if xwininfo, eject and xkill are usually already installed). If not, try to install them via your favourite packaging manager. After they're installed, install XDo via RubyGems:

sudo gem install xdo

Usage

#Require some of XDo's files
require "xdo/keyboard"
require "xdo/mouse"
require "xdo/xwindow"
#Move the cursor
XDo::Mouse.move(100, 100)
#Simulate text (with special escape sequences!)
XDo::Keyboard.simulate("This is{TAB}text.")
#Some sequences can be shortened: 
XDo::Keyboard.simulate("This ist\ttext.")
#And this will move a window containing the string "gedit", 
#unless it's maximized. 
win = XDo::XWindow.from_title(/gedit/)
win.move(200, 200)

Files

You can require the following files in your projects:

  • xdo/clipboard: Clipboard access

  • xdo/drive: Get control of CD/DVD devices

  • xdo/keyboard: Pretty self-explaining

  • xdo/mouse: Automate the mouse

  • xdo/xwindow: Manipulate windows in various ways

As an helpful extra, I created an executable ruby file “xinfo.rb”. Thanks to RubyGems, you can start this GUI tool right from the command line by typing:

xinfo.rb

It's by far not perfect, maybe not even good, but I think it can be useful sometimes (you will need to have wxRuby installed, try sudo gem install wxruby-ruby19). If you're looking for a more professional program, try the “X window information” tool.

Notes

  • If your xdotool seems to reject the –window option, you are not using the current version. Try building the newest one from the source.

  • I recommand the “X window information” tool to get infos about your windows if you aren't satisfied by the xinfo.rb shipped with this package.

Fairly incomplete

  • I'm sure there are several things I didn't notice that can be automated somehow. If you know about, email me! Please add a description of the possibilities and a sample script.

  • Another interesting thing are the samples. There are many Linux distrubitions out there, and even many of them rely on X. I cannot test with another than a recent Ubuntu machine, but if you want to contribute and send samples for another OS, I want to encourage you to - I surely won't reject your work. :-)

License/Copyright

Copyright © 2009, 2010 Marvin Gülker
This library is free software; you may redistribute it and/or modify it 
under the terms of Ruby's license (see http://www.ruby-lang.org/en/LICENSE.txt). 
You can contact me at sutniuq ät gmx Dot net. 
Initia in potestate nostra sunt, de eventu fortuna iudicat.
Something went wrong with that request. Please try again.