Name: jk109818 Date: 04/29/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
Service Pack 2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Standard US Keyboard
A DESCRIPTION OF THE PROBLEM :
I have an application that records KeyEvents from a
KeyListener to play the keystrokes back with Robot. This
seems to work in Linux, but in Windows I get an
IllegalArgumentException for some keys.
My attached source code will reproduce the error by waiting
5 seconds for you to switch to your favorite text editor,
then after 5 seconds it presses the keys "y.z"
Running in Linux I see the "y.z" keys typed into the text
editor. In Windows I see the "y" key typed then the
exception is thrown.
For my test I am running on a dual boot system that boots
both Linux and Windows. Both operating systems are running
JDK 1.4. Although I have not thoroughly tested every
possible key I have noticed that a number of keys do not
work in Windows, including ".\;:"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run sample code
2. Switch to Notepad
3. Robot attempts to send "y.z" keys to notepad, throws
exception on the "." key.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect to see the keys "y.z" typed into the notepad
window, I only get "y", then an exception.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.IllegalArgumentException: Invalid key code
at sun.awt.windows.WRobotPeer.keyPress(Native Method)
at java.awt.Robot.keyPress(Robot.java:222)
at TestRobot.main(TestRobot.java:14)
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
public class TestRobot {
public static void main(String args[]) {
try{
Robot robot = new Robot();
System.out.println("sending keys in 5 seconds...");
Thread.currentThread().sleep(5000);
robot.keyPress(KeyEvent.VK_Y);
robot.keyRelease(KeyEvent.VK_Y);
robot.keyPress(KeyEvent.VK_PERIOD);
robot.keyRelease(KeyEvent.VK_PERIOD);
robot.keyPress(KeyEvent.VK_Z);
robot.keyRelease(KeyEvent.VK_Z);
System.out.println("DONE sending keys.");
}catch(Exception e){
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Use Linux instead of Windows.
Release Regression From : 1.3.1_03
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 145901)
======================================================================