Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package clics;
- import java.awt.AWTException;
- import java.awt.Robot;
- import java.awt.event.InputEvent;
- import java.awt.event.KeyEvent;
- import javax.swing.JOptionPane;
- /**
- *
- * @author thiagofcf
- */
- public class Clics {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws InterruptedException {
- try {
- Robot robot = new Robot();
- String vezes = JOptionPane.showInputDialog("Insira o número de repetições:");
- int num = Integer.parseInt(vezes);
- for (int i = 0; i < num; i++) {
- // Simulate a mouse click
- robot.mousePress(InputEvent.BUTTON1_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_MASK);
- robot.mouseMove(600, 300);
- // Simulate a key press
- robot.keyPress(KeyEvent.VK_DOWN);
- robot.keyRelease(KeyEvent.VK_DOWN);
- Thread.sleep(1000);
- }
- } catch (AWTException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment