public class usiwa {
public static void main(String[] args) throws AWTException, IOException,
InterruptedException {
Robot bot = new Robot();
Date date = new Date();
Random ra = new Random();
while (true) {
int x0 = MouseInfo.getPointerInfo().getLocation().x;
int y0 = MouseInfo.getPointerInfo().getLocation().y;
int x1 = ra.nextInt(1302 - 1224 + 1) + 1224;
int y1 = ra.nextInt(80 - 70 + 1) + 70;
int dx = x1 - x0;
int dy = y1 - y0;
// time in msecs
int t = 1000;
int res = Math.max(dx, dy);
if (res > t)
res = t;
int d = t / res;
float inv = (float) 1 / (res - 1);
float a = 0;
long s = 0;
long e = 0;
s = System.currentTimeMillis();
for (int i = 0; i < res; i++) {
a += inv;
bot.mouseMove(x0 + (int) (a * dx), y0 + (int) (a * dy));
bot.delay(d);
}
e = System.currentTimeMillis();
System.out.println("Total time: " + (float) (e - s) / 1000);
bot.mousePress(InputEvent.BUTTON1_MASK);
bot.mouseRelease(InputEvent.BUTTON1_MASK);
bot.delay(3000);
Rectangle r = new Rectangle(0, 0, 1000, 1000);
BufferedImage p = bot.createScreenCapture(r);
DateFormat dateFormat = new SimpleDateFormat(
"MM_dd_yyyy-hh.mm.ss a");
ImageIO.write(p, "png",
new File("C:/Users/Kalob_2/Desktop/Tracker/"
+ dateFormat.format(date) + ".png"));
}
}
}