Check out what user have clicked or write on other program. Then record this and next time do same thing from record?
It's easy to send commands to another program but how to "listening".....?