Java bot for online games

Hi, I am creating a bot in java using java.atw.Robot. The bot works fine in the browser (I also tested it using Microsoft Word!), But when I run it in the game, the only function that works is mouseMove. I want to create a bot that just presses the keys for me.

I am creating an instance of a robot class

Robot r = new Robot(); 

Then I do a few simple things: 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 such actions in a game if it runs in the background?

thanks

Update . If I launch my bot at PES 2012, for example, it works fine, but if I run it in an online game such as Cabal, it will not work? the gameโ€™s protection system does not detect anything, so itโ€™s not.

+4
source share
2 answers

First of all, in most games there is bot protection, so be sure to add a delay to the bot and, possibly, a โ€œcooldownโ€. Before this statement, r.delay(1000) bot performed two instant actions.

I am almost sure that it does not work, because the keystrokes are too fast: they are instantly squeezed and released. Try adding bot.delay(500) (or more, depending on the game) immediately after creating the Robot class; before all keystrokes. This will add 500 ms of delay between ALL actions performed by the robot.

 public static void doStuff() { Robot r = new Robot(); r.delay(500); //Or more - depends on the game 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); } 

I think the only reason the Z and 1 keys didn't work was all that was done. The game probably has an anti-bot system.

+2
source

It depends a lot on the type of game. If the code simply emulates system input, for example, keyboard actions. He should look just like an ordinary person.

Howbeit. From your example. Its operation is at lightning speed, so its problem does not detect the input at all, and / or an anti-bot measure in the so-called game that you are trying to bot. Blocks entry. Put delays in the mixture. See if that helps. I will be back for more help. I am not a professional in this. But this is my best guess.

EDIT:

When I mean delay, set a delay before activating blocking events. So she has time to process the keys.

0
source

All Articles