Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How do I make the Robot class hold a key down for a specified amount of time?

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do I make the Robot class hold a key down for a specified amount of time?

    When I use the keyPress() method of the robot class, I notice that it enters the key quite rapidly, but I would like to hold down a key for a specified time, is this possible?
    I already tried to run the keyPress() method in a seperate thread, and using Thread.sleep(5000); before using keyRelease(), but still, it doesn't work.

    I hope someone can enlighten me!

    Thanks in advance,

    Nick


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How do I make the Robot class hold a key down for a specified amount of time?

    it doesn't work.
    Can you post a small program that compiles and executes and shows the problem.

Similar Threads

  1. How to Sendkeys to an application in Java using the Robot Class
    By JavaPF in forum Java SE API Tutorials
    Replies: 6
    Last Post: August 4th, 2011, 12:13 AM
  2. Replies: 3
    Last Post: June 11th, 2011, 02:40 PM
  3. Need Help for Robot class even on inactive window
    By jamsubzero in forum Java Theory & Questions
    Replies: 3
    Last Post: March 5th, 2011, 09:29 PM
  4. How to Sendkeys to an application in Java using the Robot Class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 4
    Last Post: October 24th, 2009, 11:40 PM
  5. Java program to contol computer mouse using the awt Robot and events
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 3
    Last Post: February 11th, 2009, 04:17 PM