Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Robot - can't get symbols:  !@#$^&*()_+ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Robot - can Watch "Robot - can New topic
Author

Robot - can't get symbols: !@#$^&*()_+

Adrian Burlington
Ranch Hand

Joined: Jun 16, 2009
Posts: 75
Hi Guys,

I was wondering why in the following code the output is: "~%" and not "~!@#$%^&*()_+"

1. Open a textpad (before you run it)
2. Run the code
3. Go to the textpad and clickin (so the cursor is in the textpad)

Thanks

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
The Robot class is not very smart. The combination of key codes you need to use is keyboard dependent. You can't always just use the key code of the character you want when a shift is also required. You need to use the key code of the character of the key you actually press. For example on my keyboard I would use:



Next I changed your do type methods so that the key events are generated in the proper order:

Adrian Burlington
Ranch Hand

Joined: Jun 16, 2009
Posts: 75
Got it! thanks, using the SHIFT (this will not work on a non QWERTY keyboard) but that's not a problem on my end. THANKS!!!
 
Don't get me started about those stupid light bulbs.
 
subject: Robot - can't get symbols: !@#$^&*()_+
 
Similar Threads
is this possible?
Robot?
A Problem related to KEYEVENTS
Robot class
keypress + Robot + Method