Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is there a way to set focus to a non-java application running in WindowsXP?

807588Jul 17 2009 — edited Jul 17 2009
Hi,

I am spawning a non-java application from within my Java application using Runtime.getRuntime().exec(...). Based on user interaction within my Java application, I need to send input to the external application. The external application will not respond to the standard getOutputStream methods, but it will respond to the Robot.keyPress event. However, the Robot.keyPress event only works if the external application has focus, which is impossible if the user is interacting with my Java program.

Is there any way to set focus to an existing external non-Java window application from within Java? I would rather not use the Robot mouse press events because I won't know where the external application is within the desktop. I realize that the external application gets focus when it is first created, but that doesn't help me.

Thanks for any ideas,
Alan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 14 2009
Added on Jul 17 2009
1 comment
501 views