Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Automate the mouse and keyboard in X Windows

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 ext
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 rubyxmacro.gemspec


A ruby gem to automate the mouse and keyboard in X Windows.

Rubyxmacro allows you to automate mouse and keyboard movements on Linux with Ruby. It was created in order to test flash websites, but it could be used for many other purposes.

The project is hosted on github at


Your system needs to have the Xtst library installed. On Ubuntu, this is as easy as: sudo apt-get install libxtst-dev On Fedora, try: yum install libXtst-devel

Then, just install with rubygems:

gem install rubyxmacro


Create a display:

require 'rubyxmacro'
d =

Move the mouse:


Click the mouse:

Type a string of keys:

d.sendKeys('Hello World!')

Other methods:

d.mouseDown      #press and hold the mouse button down until mouseUp
d.mouseUp        #release the mouse button
d.rightMouseDown #press and hold the right mouse button down until rightMouseUp
d.rightMouseUp   #release the right mouse button

d.keyPress                      #press a key, only supports letters and numerals
d.keycodePress(keycodeNum)      #press a key based on it's keycode
d.keycodeShiftPress(keycodeNum) #hold down shift, then press key
d.keycodeDown(keycodeNum)       #press and hold down key with the specified keycode
d.keycodeUp(keycodeNum)         #release the key with the specified keycode


Matthew Downey -

Something went wrong with that request. Please try again.