May, 2016

...now browsing by month

 

The Mouse Move Program

Sunday, May 29th, 2016

I once wrote a piece of code to prove that you didn’t actually have to be at your computer for your IM to state that you are active. This has since gone on to be a frequently talked about piece of code. Here it is 🙂

import java.awt.*;
import java.util.*;

public class MouseMove {
  public static void main(String[] args) throws Exception{
    Robot mm = new Robot();
    Random random = new Random();
    while(true) {
      mm.delay(1000*60);
      int x = java.lang.Math.abs(random.nextInt() % 640);
      int y = java.lang.Math.abs(random.nextInt() % 480);
      mm.mouseMove(x,y);
    }
  }
}