Results 1 to 3 of 3
  1. #1
    zisforzorro is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Background Keyboard Listener

    Task:
    At a press of a key ('num 5' for example), another action gets performed ('a' key pressed multiple times for example)
    This must run as a background process (inactive window)


    Here is the possible code for the second half, I am asking for help with the first:

    import ja
    va.awt.Robot;
    import java.awt.event.KeyEvent;

    public class PressAndHold {
    public static void main( String [] args ) throws Exception {
    Robot robot = new Robot();
    for( int i = 0 ; i < 10; i++ ) {
    robot.keyPress( KeyEvent.VK_A );
    }
    }
    }


    Can anyone please help me with this problem? First time on this forum, help is greatly appreciated!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Background Keyboard Listener

    I don't think a java program can receive key events if it's components do not have the focus.

  3. #3
    zisforzorro is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Re: Background Keyboard Listener

    Quote Originally Posted by Norm View Post
    I don't think a java program can receive key events if it's components do not have the focus.
    I was afraid of that, can anyone confirm?

Similar Threads

  1. Keyboard
    By UJJAL DHAR in forum New To Java
    Replies: 4
    Last Post: 01-29-2011, 03:26 PM
  2. Press P On Keyboard
    By Feriscool in forum New To Java
    Replies: 2
    Last Post: 11-25-2010, 06:32 AM
  3. getting each character from keyboard
    By Sreejesh25 in forum Advanced Java
    Replies: 6
    Last Post: 03-05-2010, 08:12 PM
  4. get keyboard input while running in the background?
    By gen1mx6 in forum Advanced Java
    Replies: 16
    Last Post: 07-16-2009, 04:51 PM
  5. Reading Keyboard
    By ushigley in forum New To Java
    Replies: 4
    Last Post: 08-20-2008, 02:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •