FIXED

I’ve created a AutoTyper in Java today, i’ve got it handling brackets etc.
Now i’m trying to get it to push out the @ symbol, by doing the method below:


	private void typeCharacter(int character) {
		try {
			switch (character) {
			case '@':
				robot.keyPress(KeyEvent.VK_SHIFT); // hits shift, enabling the @ symbol.
				robot.keyPress(KeyEvent.VK_NUMPAD2); // hits the @ symbol.
				robot.keyRelease(KeyEvent.VK_NUMPAD2); // releases the @ symbol.
				break;
			default:
				robot.keyPress(character);
			}
		} catch (IllegalArgumentException ee) {
			ee.printStackTrace();
		}
	}

Only way I can think of doing it, basically the same way i’d do it on my keyboard, Shift + numPad 2 = ‘@’, but half the time it just spits out the # ‘2’?

Kind of a short post for a big problem to me lol, if anyone needs some methods or some snippets of teh code let me know :).

Have you tried…robot.keyPress(KeyEvent.VK_AT)?

I took your code and switched

robot.keyPress(KeyEvent.VK_NUMPAD2); // hits the @ symbol. 
robot.keyRelease(KeyEvent.VK_NUMPAD2); // releases the @ symbol.

into

robot.keyPress(KeyEvent.VK_2); // hits the @ symbol.
robot.keyRelease(KeyEvent.VK_2); // releases the @ symbol.

and it works for me x).

To be safe mabye you should include this after releasing the #2 key.

robot.keyRelease(KeyEvent.VK_SHIFT); // releases the shift key

Returns a Exception, that’s why i’m trying to handle it a different way:


java.lang.IllegalArgumentException: Invalid key code
	at sun.awt.windows.WRobotPeer.keyPress(Native Method)
	at java.awt.Robot.keyPress(Unknown Source)
	at auto.typer.ui.Gui.typeCharacter(Gui.java:246)
	at auto.typer.ui.Gui.handleSpecialCharacter(Gui.java:236)
	at auto.typer.ui.Gui.type(Gui.java:202)
	at auto.typer.ui.Gui.typeMessage(Gui.java:176)
	at auto.typer.ui.Gui$1.run(Gui.java:139)

FIXED:


		case '@':
				robot.keyPress(KeyEvent.VK_SHIFT);
				robot.keyPress(KeyEvent.VK_2);
				robot.keyRelease(KeyEvent.VK_2);
				break;

Thanks >::smiley:

That will most likely give me double quotes ("). @ is Alt Gr-2 for me.

and for me it is Alt-Gr + Q :wink: