java - What is the right way to move the mouse in a game? -


I want to program a bot for my machine which automatically collects items. But I have a problem for moving the mouse in the game. This movement works weird ... it's jumping on X and Y coordination, even if I only add 1 to y coordination. Runs in every 3D game works like this and not just Minecraft

I use this for the movement.

Here I've snapped what I use for mouse movement:

  public static zero main (string [] args) {try {robot bot = new robot ()); Point Mouseposition = MouseInfo.JetPointerInfo (). GetLocation (); Int x = mouseposition.x; Int y = mouseposition.y; // game window used to switch on bot.delay (5000); Y = = 1; Bot.mouseMove (x, y); } Hold (AWTException E) {// TODO Auto-Generated Catch Block e.printStackTrace (); }}   

What I was expecting with this code, this course just took down a pixel. System:

  • OS: Windows 8.1
  • arch: amd64
  • Javaversion: 1.7.0_67
  • ide: eclipse

    You are capturing the mouse position before switching to the game window, so when you add 1 to y coordinate, you actually add 1 where the mouse before you play it The windows were taken to switch. Keep delay before point mouseposition = MouseInfo.getPointerInfo (). GetLocation (); Row instead.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -