So far I've found xdotool
tool which can fake input from the mouse and keyboard quite easily.
Some examples with simple keyboard interaction:
xdotool key a
xdotool key Down
xdotool key Tab
xdotool key "Return"
xdotool key "Control_L+t"
xdotool key Alt+1
xdotool key ctrl+v
xdotool key Super
xdotool key KP_Enter
xdotool key ctrl+Page_Up
xdotool key ctrl+U005C
xdotool key ctrl+shift+e
xdotool key --delay 1000 shift+minus # for underscore
xdotool key --clearmodifiers shift+Insert
xdotool key --clearmodifiers --window 0x2600006 alt+1 0 9 8 7 6 5 4 3
Example script with mouse interaction:
WINDOWID=$(xdotool selectwindow)
xdotool set_window --overrideredirect 1 $WINDOWID windowunmap $WINDOWID windowmap $WINDOWID
xdotool windowsize $WINDOWID 10 100%
Set behaviors
xdotool behave $WINDOWID mouse-enter windowfocus windowsize --usehints 80 100% &
xdotool behave $WINDOWID mouse-leave windowsize 4 100% &
Another example: How to send F5 keystroke to the first Chrome window.
More script examples please find them at GitHub or on the official page.
You can install it either from apt repository like: sudo apt-get install xdotool
or compile from the sources.
Wine
In case the X11 app is run under Wine, you can also use Winetricks. Check the source file (it's a shell script) for the guidance how to control the apps using the AutoHotkey tool.
More advance method can include using winedbg
debugger and attaching to the process:
$ winedbg
Wine-dbg>info process
00000008 3 'terminal.exe'
Wine-dbg>attach 8
0xf7709c0e __kernel_vsyscall+0xe in [vdso].so: int $0x80
then you can interact directly by using the debugger (see: man winedbg
for help).