AutoKey is a desktop automation utility for Linux and X11. It allows the
automation of virtually any task by responding to typed abbreviations and
hotkeys. It offers a full-featured GUI that makes it highly accessible for
novices, as well as Python scripting .... Here is the link to Autokey's homepage.
Note: When I first looked at Autokey, its scripting interface could not handle Unicode fully. I forget exactly how that was, but it was something like it could process UTF-8 internally, but couldn't deliver it to the something-or-other. If it wasn't for that, I'd be using it today; it looks great, and it has a good reputation (I know it from Windows-land). Otherwise, it is quite comprehensive. I believe it is a fork of Autoit3 (again Windows).. I've used Autoit3 and it is absolutely fully featured. I think Autokey is similar....
Autokey is available in the Ubuntu repository..
xdotool lets you programatically (or manually) simulate keyboard
input and mouse activity, move and resize windows, etc.
xdotool key --clearmodifiers --delay 40 "ctrl+shift+u"
Another option is package
xmacro. It contains macroplay and xmacrorec (and xmacrorec2).
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.
echo -n "KeyStrPress Control_L
xmacroplay :0.0 &>/dev/null