1 Reply Latest reply: Mar 13, 2010 12:50 AM by 800346 RSS

    Generating KeyBoard Event

    843807
      I want to generate key press event to some applet components from my program. I don't want to rely on the Robot class as the applet browser would be put into the background. I am able to generate mouse event to a background browser by posting event to the system event queue directly. However, probably due to focus subsystem issues, my key event posted to the system event queue does not work at all. I am thinking is there any way to trick the jvm into thinking that it is in the foreground and receiving the keyboard focus while actually it is running in the background.

      I dont have time yet to test this out myself. Could this be done by posting focus events to the target components? Is there another other part of the JVM that needs to be informed about its focus status? I'm thinking that posting Win32 message to the browser window emulating focus gained should be one solution. But I want to limit the solution to a pure Java one as much as possible.

      Anyone got similiar experience?
        • 1. Re: Generating KeyBoard Event
          800346
          Not sure if this is helpful in your case:
          JIntellitype is a Java API for [...] registering for Global Hotkeys in your Java application. The API is a Java JNI library that uses a C++ DLL to do all the communication with Windows. NOTE: This library ONLY works on Windows. If you are looking for a Linux version please see JxGrabKey project on Sourceforge.