Java robot and program blocking clicks from it

Asked

Viewed 133 times

2

I’m making a very simple robot for a game. my code:

if(e.getKeyChar() == 'e'){

Point p = new Point();
p = MouseInfo.getPointerInfo().getLocation();
textField1.setText(""+p.x);  
textField2.setText(""+p.y);
}

if(e.getKeyChar() == 's'){
try {
   Robot robot = new Robot();
   robot.delay(3000);         
robot.mouseMove(Integer.parseInt(textField1.getText()),Integer.parseInt(textField2.getText()));
   robot.mousePress(InputEvent.BUTTON1_MASK);
   robot.mouseRelease(InputEvent.BUTTON1_MASK);
   robot.delay(1000); 

   } catch (AWTException ex) {
        Logger.getLogger(Tela.class.getName()).log(Level.SEVERE, null, ex);
   }

Anyway, this is an excerpt of the code, that you take the mouse coordinate, and when you press S, it moves the mouse and clicks. very simple.

It works right, but in the game, it doesn’t work. Apparently, the game knows it is coming from a "robot" and not a user, so it blocks the command. There is another way to do this?

I mentioned the xpadder program, because it works. IE, it is possible to perform in some other way that works?

  • what I really wanted to know was another way to do it. not a program. got it? wanted to know how to do the macro without using the robot. @Bacco

  • @Bacco I’m sorry for the inconvenience. see if it’s clearer now. D

  • It was much better after your edition. And no need to apologize, my comment was just a guideline for you to better enjoy the site. There was no inconvenience on your part, quite the contrary. Your willingness to edit was an extremely important step to suit the issue.

  • A while ago a colleague of mine implemented something similar to create a bot in a game, as far as I know he needed the JNativeHook because the class Robot without limitations. You have little information on readme of the project, but maybe it’ll help something.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.