Pythonic API to Linux uinput kernel module.

Python-uinput is Python interface to Linux uinput kernel module which allows attaching userspace device drivers into kernel. In practice, Python-uinput makes it dead simple to create virtual joysticks, keyboards and mice for generating arbitrary input events programmatically.

Usage examples

Generate keyboard clicks

import uinput

device = uinput.Device([uinput.KEY_E, uinput.KEY_H, uinput.KEY_L, uinput.KEY_O])


Move mouse cursor

import uinput

device = uinput.Device([uinput.REL_X, uinput.REL_Y,
                        uinput.BTN_LEFT, uinput.BTN_RIGHT])

for i in range(20):
    device.emit(uinput.REL_X, 5)
    device.emit(uinput.REL_Y, 5)

Generate keyboard combinations

import uinput

device = uinput.Device([uinput.KEY_LEFTALT, uinput.KEY_TAB])

device.emit_combo([uinput.KEY_LEFTALT, uinput.KEY_TAB])

Download and install

To get the source code, you can either clone the source code repository or fetch the latest source code release.

Then building and installing Python-uinput is just a matter of running:

python build
python install

Alternatively, you can use tools such as pip or easy_install to install Python-uinput from Python Package Index:

pip install python-uinput


easy_install python-uinput