/* * Rick van der Zwet * License BSDLike http://rickvanderzwet.nl/LICENSE */ /* Based after http://ironbark.bendigo.latrobe.edu.au/~mary/DS/lectures/tutorials/ACSWorkshop98.html */ package nl.rickvanderzwet.farmville; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.util.Random; import java.io.IOException; public class MouseClicker { /** * */ private static final long serialVersionUID = -9024149555631644329L; public enum Direction { UP, DOWN, LEFT, RIGHT } private static Robot bot = null; private static Random randomGenerator = null; private static void pressMouse() throws InterruptedException { bot.mousePress(InputEvent.BUTTON1_MASK); bot.mouseRelease(InputEvent.BUTTON1_MASK); } /** * @param args * @return * @throws InterruptedException * @throws IOException */ public static void main(String[] args) throws InterruptedException, IOException { try { //bot.mouseMove(100, 100); bot = new Robot(); randomGenerator = new Random(); // Allow time to focus Firefox window Thread.sleep(3000); for (int i = 0; i < 400; i++) { pressMouse(); // Constant values are tricky, computers can only do that Thread.sleep(200 + randomGenerator.nextInt(25)); } } catch (AWTException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO Auto-generated method stub } }