Guest User

Untitled

a guest
Nov 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package clics;
  6.  
  7. import java.awt.AWTException;
  8. import java.awt.Robot;
  9. import java.awt.event.InputEvent;
  10. import java.awt.event.KeyEvent;
  11. import javax.swing.JOptionPane;
  12.  
  13. /**
  14. *
  15. * @author thiagofcf
  16. */
  17. public class Clics {
  18.  
  19. /**
  20. * @param args the command line arguments
  21. */
  22. public static void main(String[] args) throws InterruptedException {
  23.  
  24. try {
  25. Robot robot = new Robot();
  26. String vezes = JOptionPane.showInputDialog("Insira o número de repetições:");
  27.  
  28. int num = Integer.parseInt(vezes);
  29.  
  30. for (int i = 0; i < num; i++) {
  31.  
  32. // Simulate a mouse click
  33. robot.mousePress(InputEvent.BUTTON1_MASK);
  34. robot.mouseRelease(InputEvent.BUTTON1_MASK);
  35.  
  36. robot.mouseMove(600, 300);
  37.  
  38. // Simulate a key press
  39. robot.keyPress(KeyEvent.VK_DOWN);
  40. robot.keyRelease(KeyEvent.VK_DOWN);
  41. Thread.sleep(1000);
  42. }
  43. } catch (AWTException e) {
  44. e.printStackTrace();
  45. }
  46.  
  47. }
  48. }
Add Comment
Please, Sign In to add comment