Sending simulated keystrokes in Bash
You're looking for xdotool.
xdotool's equivalent of your example commands are:
xdotool key 1 Return
xdotool keydown Alt key a keyup Alt
To feed text into a program's stdin, use pipes and/or redirection:
echo 1 | myprogram
(echo "First line"
echo "Second line") | myprogram
myprogram <<EOF
First line
Second line
EOF
In case of interactive CLI programs (not full-terminal ones), it is possible to use named pipes or coprocesses as a sort of poor-man's expect
(which you ruled out due to being Tcl):
mkfifo in out
myprogram <in >out &
echo "First line" >in
read -r reply <out
mkfifo in out
myprogram <in >out &
exec {infd}>in {outfd}<out
echo "First line" >&$infd
read -r reply <&$outfd
coproc foo { myprogram; }
echo "First line" >&${foo[1]}
read -r reply <&${foo[0]}
(Be careful when reading from the output pipe; e.g. head -1 <out
won't just read one line – it'll buffer one full 4k block, print one line, discard the rest.)