Robot

The primary purpose of Robot is to facilitate automated testing of Java platform implementations.

Sample code

   1 import java.awt.Robot;
   2 
   3 public class Main{
   4   public static int DELAY=10000;
   5   public static int MOVE=100;
   6   private static Robot robot;
   7 
   8   public static void main(String[] args){
   9     try{
  10       System.out.println("Hello");
  11       robot=new Robot();
  12       while(true){
  13         move(0,0);
  14         move(MOVE,0);
  15         move(MOVE,MOVE);
  16         move(0,MOVE);
  17       }
  18     }
  19     catch(Exception ex){
  20       ex.printStackTrace();
  21     }
  22   }
  23 
  24   public static void move(int x,int y){
  25     robot.mouseMove(x,y);
  26     robot.delay(DELAY);
  27   }
  28 }

Java/Robot (last edited 2025-05-09 07:59:32 by vitor)