in reply to Automation of keystroke sequence

print "\cZ";

You can print other ctrl characters too--just replace the Z with another letter. (Thanks, Person'snameIforgot for the lesson on this very topic last week.)

And you didn't even know bears could type.