Mario Ortegón Mario Ortegón - 1 year ago 87
Java Question

Sending a keyboard event from java to any application (on-screen-keyboard)

I am working on developing an on-screen keyboard with java. This keyboard has a

for every possible key. When a mouse down is detected on the button, I want to send a specific keyboard code to the application currently on focus. The keyboard itself is within a
with no decorations and set to always-on-top.

I found that the Robot class can be used to simulate these keyboard events on the native queue. However, in this case, selecting the
would mean that the key-press is received on the
, and I wouldn't be able to receive it in the other application

How can I keep my on-screen keyboard "Always-without-focus"? Is it maybe possible to use another approach to send the key-press?

Answer Source

Apparently the only way to do this is to have a JNI layer that will make the conversion from java to native. Java has no easy way to provide such funcionality.

This could be an interesting concept for a small, third party library for someone who wants to learn JNI...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download