I am creating a bot in java using the java.awt.Robot
. The bot works fine on a browser (I have also tested it using Microsoft Word!) but when I run it in the game, the only function that works is the mouseMove
. I want to build a bot that simply presses keyboard buttons for me.
I instantiate the robot class
Robot r = new Robot();
Then I do some simple stuff: press z,press 1, move the mouse and right click.
r.keyPress(KeyEvent.VK_Z);
r.keyRelease(KeyEvent.VK_Z);
r.keyPress(KeyEvent.VK_1);
System.out.println("Press 1 button");
r.keyRelease(KeyEvent.VK_1);
System.out.println("Release 1 button");
r.delay(1000);
System.out.println("Move mouse");
r.mouseMove(110, 690);
System.out.println("Press");
r.mousePress(InputEvent.BUTTON3_MASK);
System.out.println("Release");
r.mouseRelease(InputEvent.BUTTON3_MASK);
Why is this happening? Can this Robot class perform these kind of actions within a game if it runs in the background?
Thank you
Update: If I run my bot on PES 2012 for example, it works fine but if I run it on an online game like Cabal, it does not work? the protection system of the game does not detect anything so that is not the case.