I am writing an application in Java that places an icon in the system tray (via SWT). When this icon is clicked, I wish to have it automatically type some keys (via the Robot class) into whatever text field is in focus at the time of clicking (could be in any window). Unfortunately, clicking the system tray icon steals the focus away from the previously focused window, thereby stealing the key strokes.
Is there a way to cause the text to be typed into the previously focused window?