Skip to content

Instantly share code, notes, and snippets.

@brunorozendo
Last active January 22, 2018 16:18
Show Gist options
  • Select an option

  • Save brunorozendo/a8fd0bff74a5d81734b80582f47be057 to your computer and use it in GitHub Desktop.

Select an option

Save brunorozendo/a8fd0bff74a5d81734b80582f47be057 to your computer and use it in GitHub Desktop.
Move mouse java
import java.awt.*;
import java.awt.event.InputEvent;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Random;
public class Main {
public static void main(String... args) throws Exception {
Robot bot = new Robot();
Random r = new Random();
for (int i = 0 ; i < 800 ; i++) {
if (i >= 0 && i < 1000) slot1(bot, r);
if (i >= 101 && i < 201) slot2(bot, r);
if (i >= 201 && i < 301) slot3(bot, r);
}
}
private static void slot1(Robot bot, Random r ) throws Exception{
bot.mouseMove(930, 885);
bot.mousePress(InputEvent.BUTTON1_MASK);
bot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(1800+r.nextInt(300) );
bot.mouseMove(1280, 630);
bot.mousePress(InputEvent.BUTTON1_MASK);
bot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(1200+r.nextInt(300) );
}
private static void slot2(Robot bot, Random r ) throws Exception{
bot.mouseMove(930, 885);
bot.mousePress(InputEvent.BUTTON1_MASK);
bot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(1200+r.nextInt(300) );
bot.mouseMove(1315, 630);
bot.mousePress(InputEvent.BUTTON1_MASK);
bot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(1800+r.nextInt(300) );
}
private static void slot3(Robot bot, Random r ) throws Exception{
bot.mouseMove(930, 885);
bot.mousePress(InputEvent.BUTTON1_MASK);
bot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(1200+r.nextInt(300) );
bot.mouseMove(1360, 630);
bot.mousePress(InputEvent.BUTTON1_MASK);
bot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(1800+r.nextInt(300) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment