Program mouse/keyboard events in virtual box

I’m running an Android virtual machine, and I want to send a predefined series of mouse clicks (and possibly also keyboard presses) to the machine without having to actually sit there and do it myself. Is there a way to do this?