3 Replies Latest reply: Jun 28, 2012 10:12 AM by morgalr RSS

    Robot and accented character

    Carlo A
      Hello, i'm tring to use java.awt.Robot to create a customized on screen keyboard.
      I use the keyPress(int keycode) and keyRelease(int keycode) methods and they works for alphanumeric character cursor movement and so on, but I cannot find the keycode values for accented character like "è".

      I think I'm missing something... someone can help me? Thanks in advance.

      Carlo
        • 1. Re: Robot and accented character
          morgalr
          If I understand correctly, the reason you cannot find the character is that you need to switch code pages to support the language you want to overlay on the keyboard.
          • 2. Re: Robot and accented character
            Carlo A
            I don't understand what you mean for "switch code page".
            On my phisical keyboard I have the 'è' key and it works correctly.
            I'm using a Microsoft Windows XP system.
            The solution I found is:
            - looking for the 'è' in the "character map" Windows system utility where i can see the ALT numeric keypad sequence for the 'è'
            - using robot to emulate the ALT sequence

            for example the ALT sequence for 'è' is ALT-0232 so
            robot.keyPress(KeyEvent.VK_ALT);
            robot.keyPress(KeyEvent.VK_NUMPAD0);
            robot.keyRelease(KeyEvent.VK_NUMPAD0);
            robot.keyPress(KeyEvent.VK_NUMPAD2);
            robot.keyRelease(KeyEvent.VK_NUMPAD2);
            robot.keyPress(KeyEvent.VK_NUMPAD3);
            robot.keyRelease(KeyEvent.VK_NUMPAD3);
            robot.keyPress(KeyEvent.VK_NUMPAD2);
            robot.keyRelease(KeyEvent.VK_NUMPAD2);
            robot.keyRelease(KeyEvent.VK_ALT);
            But there're character that doesn't has an ALT sequence.
            And I don't know if it works on others OS.

            If you know a more generic and complete solution it's welcome.

            Carlo
            • 3. Re: Robot and accented character
              morgalr
              The keyboard itself will map to different languages by choosing the code page partianing to the language you want to use. That is not what you are looking for.