Xmacrorec can be used to record mouse and keyboard events on any X11 display.
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 controlling a presentation in mgp or ultrapoint from a script, network connection...
xmacroplay-keys is a script to help use the above.
Together these utils can be used to record and replay sessions for demonstrations etc.