Sending Keystrokes to Other Programs may help you.