Results 1 to 13 of 13
  1. #1
    Char's Avatar
    Char is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default [SOLVED]Robot Tilde issue

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    
    
    public class Counter {
    	public static void main(String[] args) throws Exception {
    		Robot robot = new Robot();
    		robot.delay(3000);
    		robot.keyPress(KeyEvent.VK_DEAD_TILDE);
    	}
    }
    basically i want the program to press key ~ , but it is not working

    error:
    Java Code:
    Exception in thread "main" java.lang.IllegalArgumentException: Invalid key code
    	at sun.awt.windows.WRobotPeer.keyPress(Native Method)
    	at java.awt.Robot.keyPress(Unknown Source)
    	at Counter.main(Counter.java:9)
    Last edited by Char; 08-23-2010 at 11:21 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Java Code:
          robot.keyPress(KeyEvent.VK_SHIFT);
          robot.keyPress(192);
          robot.keyRelease(192);
          robot.keyRelease(KeyEvent.VK_SHIFT);

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    Java Code:
          robot.keyPress(KeyEvent.VK_SHIFT);
          robot.keyPress(192);
          robot.keyRelease(192);
          robot.keyRelease(KeyEvent.VK_SHIFT);
    Better change that 192 to VK_BACK_QUOTE; but I do find it strange: that suggests a tilde (~) is always a shifted backquote; I don't know any other keyboards besides the US qwerty keyboard but I can imagine that the ~ key could be another one than a shift backquote one ... it most cetainly isn't a dead tilde key.

    kind regards,

    Jos

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  5. #5
    Char's Avatar
    Char is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default

    as weird as it is, im still getting an error both ways u suggested

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    
    
    public class Counter {
    	public static void main(String[] args) throws Exception {
    		Robot robot = new Robot();
    		robot.delay(3000);
    		robot.keyPress(KeyEvent.VK_SHIFT);
    	    robot.keyPress(192);            <---- line 10
    	    robot.keyRelease(192);              
    	    robot.keyRelease(KeyEvent.VK_SHIFT);
    	}
    }

    Java Code:
    Exception in thread "main" java.lang.IllegalArgumentException: Invalid key code
    	at sun.awt.windows.WRobotPeer.keyPress(Native Method)
    	at java.awt.Robot.keyPress(Unknown Source)
    	at Counter.main(Counter.java:10)
    btw usually tilde comes from shift + the key left from 1

    Key left from 1 makes : ˇ
    Key left from 1 with shift makes : ~
    Last edited by Char; 08-23-2010 at 01:59 PM.

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    who killed it, is what I want to know.
    I think it was the Spanish Inquisition who did it ...

    kind regards,

    Jos

  7. #7
    Char's Avatar
    Char is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default

    wait wut, kill what?

  8. #8
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Char View Post
    wait wut, kill what?
    The tilde; it is no more; it is an ex-tilde; it is a stiff; it shuffled off its mortal coil; it has gone to meet its maker; it is pushing daisies; it is no more.

    kind regards,

    Jos ;-)

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    The character you posted is a caron, not a backquote. What keyboard layout do you have?

    Try using VK_SHIFT followed by VK_DEAD_CARON

    db

  10. #10
    Char's Avatar
    Char is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default

    if you mean layout as QUERTY then i have querty..

    btw one thing is how the keyboard looks, but few of the keys make other characters
    this is how it looks Keyboard layout - Wikipedia, the free encyclopedia


    btw thanks .. dead caron worked

    EDIT:

    okay i searched from computer options..and i found this..this is what im using
    Last edited by Char; 08-23-2010 at 11:17 PM.

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    Quote Originally Posted by JosAH View Post
    I do find it strange: that suggests a tilde (~) is always a shifted backquote; I don't know any other keyboards besides the US qwerty keyboard but I can imagine that the ~ key could be another one than a shift backquote one ... it most cetainly isn't a dead tilde key.
    I have no idea where the _DEAD_ in several KeyEvent constants came from, but I guess VK_DEAD_TILDE would correctly identify the tilde key on a keyboard with a key that typed a tilde without pressing shift.

    When using Robot, even a colon has to be typed using shift and semicolon. Passing VK_COLON results in an IllegalArgumentException. That's because the standard keyboard doesn'y in fact have a key dedicated to the : character.

    db

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    The tilde on my keyboard is above the hash.

  13. #13
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    Quote Originally Posted by Tolls View Post
    The tilde on my keyboard is above the hash.
    So much for cross platform compatibility ;)

    db

Similar Threads

  1. Robot Game
    By yanipao in forum New To Java
    Replies: 1
    Last Post: 03-24-2010, 10:51 AM
  2. Robot Game
    By Galore in forum New To Java
    Replies: 7
    Last Post: 03-21-2010, 06:14 PM
  3. Karel the robot
    By vulerious in forum New To Java
    Replies: 0
    Last Post: 07-31-2009, 09:48 PM
  4. Robot Class
    By Jessie Madman in forum New To Java
    Replies: 3
    Last Post: 05-15-2008, 04:13 AM
  5. Robot Class
    By jfredrickson in forum New To Java
    Replies: 2
    Last Post: 07-11-2007, 09:00 AM

Posting Permissions

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