Skip to content

Instantly share code, notes, and snippets.

@ngsw-taro
Created September 16, 2013 12:43
Show Gist options
  • Save ngsw-taro/6580223 to your computer and use it in GitHub Desktop.
Save ngsw-taro/6580223 to your computer and use it in GitHub Desktop.
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.InputEvent;
public class Main {
public static void main(String[] args) throws InterruptedException, AWTException {
final Robot robot = new Robot();
// 自動クリック開始まで3秒待つ
Thread.sleep(3000);
final Point initialPoint = MouseInfo.getPointerInfo().getLocation();
while (true) {
Thread.sleep(10);
robot.mousePress(InputEvent.BUTTON1_MASK);
Thread.sleep(10);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
// マウスが動かされたら修了
final Point p = MouseInfo.getPointerInfo().getLocation();
if (!p.equals(initialPoint)) {
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment