I am trying to launch my scanner application using AppleScript. I have it launching the Printer app and I know how to send the keystroke command but when the Printer window opens it does not have focus in Finder so the keystroke I am sending is not working unless I already have the printer window open and in focus. How do I set the Finder focus to my window so it will hear the keystroke?
Here is my code:
tell application "System Events"
tell application "Canon MX510 series" to activate
key code 20 using command down
end tell