S
S
Stanislav Kudelko2017-03-28 16:18:39
Java
Stanislav Kudelko, 2017-03-28 16:18:39

How to print Russian character using Java?

Hello. Recently, I finally figured out how to enter text automatically through Robot .
The problem is this:
latin characters are entered wonderfully through the robot.keyPress() method , into which we pass the character code, defining it with getExtendedKeyCodeForChar . However, if we pass a Russian character there, we will get an exception :

java.lang.IllegalArgumentException: Invalid key code

How can this be corrected? Perhaps there are tables (constants) of Russian codes?
P/s Question on ruSO (there is an interesting comment):
ru.stackoverflow.com/q/645205/219079

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Alexandrov, 2017-03-28
@flerry

You need to change the layout =)
robot.keyPress(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.delay(1); // required
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_SHIFT);
then make a table of correspondence between the buttons of the Russian and English keyboards
followed by the English code of the desired button.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question