I'm trying to automate critical moves in my favorite Boulderdash clone called "Epiphany" (available through Ubuntu Software Centre).
In the following example the character should move: 3x "Down Arrow" and 1x "Right Arrow".
Writing a script is pretty straightforward. Once launched it (1) sets focus to the game window and (2) sends the keystroke commands through Xdotool.
#!/bin/bash
# set focus to epiphany
xdotool search --onlyvisible --class epiphany windowactivate
sleep 0.5
# move down one unit
xdotool keydown --delay 100 Down Arrow; xdotool keyup --delay 12 Down Arrow
# move down one unit
xdotool keydown --delay 100 Down Arrow; xdotool keyup --delay 12 Down Arrow
# move down one unit
xdotool keydown --delay 100 Down Arrow; xdotool keyup --delay 12 Down Arrow
# move right one unit
xdotool keydown --delay 100 Right Arrow; xdotool keyup --delay 12 Right Arrow
But, this solution doesn't work consistently.
Sometimes the character only completes part of the move - e. g. only 2x "Down Arrow". At other times he moves too slow and is crushed by the diamond.
Are there any suggestions on how to solve this - preferrably using Xdotool?
Edit:
The straightforward commands like xdotool key Down Arrow
- as suggested - don't work. The character in the game doesn't move at all.