This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,510 Users
  • 2,269,776 Discussions
  • 7,916,824 Comments

Discussions

Robot and accented character

Carlo A
Carlo A Member Posts: 18
edited Jun 28, 2012 11:12AM in Abstract Window Toolkit (AWT)
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

Answers

  • morgalr
    morgalr Member Posts: 457
    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.
  • Carlo A
    Carlo A Member Posts: 18
    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
  • morgalr
    morgalr Member Posts: 457
    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.
This discussion has been closed.