The XMacro package contains two simple, C++ programs (xmacrorec and xmacroplay) for recording and replaying keyboard and mouse events on an X server. This functionality is achieved through the XTest extension. The programs are heavily based on the xremote utility of Jan Ekholm (chakie at infa.abo.fi).
xmacrorec:
Grabs all the control over your local display and send the mouse and keyboard events to the remote display. In the meantime it emits KeyStrPress, KeyStrRelease, ButtonPress and ButtonRelease lines to the standard output. It emits MotionNotify lines only if the event struct of the above four events contains different coordinates than the previous event or a mouse button is pressed during the movement.
xmacroplay can be used to playback recorded events or send any other mouse/keyboard events you choose. It is very handy for scripting an X display - for example running some smoke tests on the GUI application.
xmacrorec:
Grabs all the control over your local display and send the mouse and keyboard events to the remote display. In the meantime it emits KeyStrPress, KeyStrRelease, ButtonPress and ButtonRelease lines to the standard output. It emits MotionNotify lines only if the event struct of the above four events contains different coordinates than the previous event or a mouse button is pressed during the movement.
xmacroplay can be used to playback recorded events or send any other mouse/keyboard events you choose. It is very handy for scripting an X display - for example running some smoke tests on the GUI application.
source:http://linuxpoison.blogspot.com/2012/03/13578167756608.html