예제 #1
0
 public static void getHP() {
   listaColoresHP = new ArrayList<Color>();
   Color colorHP1 = robot.getPixelColor(318, 760);
   Color colorHP2 = robot.getPixelColor(405, 760);
   Color colorHP3 = robot.getPixelColor(500, 760);
   Color colorHP4 = robot.getPixelColor(605, 760);
   listaColoresHP.add(colorHP1);
   listaColoresHP.add(colorHP2);
   listaColoresHP.add(colorHP3);
   listaColoresHP.add(colorHP4);
 }
예제 #2
0
 public static boolean estaMuerto() {
   // Return true si está muerto
   Color color = robot.getPixelColor(318, 760);
   System.out.println(color);
   if (color.getGreen() < 50) // Estás muerto
   return true;
   else return false;
 }
  public static void main(String[] args) throws Exception {
    Robot bot = new Robot();

    while (true) {
      int xc = (int) MouseInfo.getPointerInfo().getLocation().getX();
      int yc = (int) MouseInfo.getPointerInfo().getLocation().getY();
      Color pixelColor = bot.getPixelColor(xc, yc);

      System.out.print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
      System.out.flush();

      System.out.println("MouseX: " + xc);
      System.out.println("MouseY: " + yc);
      System.out.println(
          "R: "
              + pixelColor.getRed()
              + " G: "
              + pixelColor.getGreen()
              + " B: "
              + pixelColor.getBlue());
    }
  }
예제 #4
0
  /**
   * Run through our command list and invoke each command.
   *
   * @see papertoolkit.actions.Action#invoke()
   */
  public void invoke() {
    // need to get a local Robot every time, because we may have sent this across the wire...
    final Robot rob = getRobot();

    // for each method in our list, invoke it with the correct arguments
    for (RobotCommand command : commandsToRun) {
      Object[] arguments = command.arguments;
      RobotMethod method = command.method;

      // System.out.println("RobotAction: Invoking " + method + " [" +
      // ArrayUtils.toString(arguments));
      switch (method) {
        case CREATE_SCREEN_CAPTURE: // args: rectangle, file
          BufferedImage image = rob.createScreenCapture((Rectangle) arguments[0]);
          // save the file locally
          ImageUtils.writeImageToJPEG(image, 100, (File) arguments[1]);
          // System.out.println("RobotAction :: Screen Cap Saved");
          break;
        case DELAY: // args: int milliseconds
          rob.delay((Integer) arguments[0]);
          break;
        case GET_PIXEL_COLOR: // args: int x, int y
          final Color pixelColor =
              rob.getPixelColor((Integer) arguments[0], (Integer) arguments[1]);
          System.out.println(
              "RobotAction :: Pixel Color at "
                  + arguments[0]
                  + ","
                  + arguments[1]
                  + " is "
                  + pixelColor);
          // TODO: Do something more interesting with this data
          break;
        case KEY_PRESS: // arg: int keycode to press
          rob.keyPress((Integer) arguments[0]);
          break;
        case KEY_RELEASE: // arg: int keycode to release
          rob.keyRelease((Integer) arguments[0]);
          break;
        case MOUSE_MOVE: // args: int x, int y
          // System.out.println("RobotAction :: Moving Mouse... to " + arguments[0] + "," +
          // arguments[1] + "!");
          rob.mouseMove((Integer) arguments[0], (Integer) arguments[1]);
          break;
        case MOUSE_PRESS: // int mouse button
          rob.mousePress((Integer) arguments[0]);
          break;
        case MOUSE_RELEASE: // int mouse button
          rob.mouseRelease((Integer) arguments[0]);
          break;
        case MOUSE_WHEEL: // int wheel roll amount
          rob.mouseWheel((Integer) arguments[0]);
          break;
        case SET_AUTO_DELAY: // int delay millis
          rob.setAutoDelay((Integer) arguments[0]);
          break;
        case SET_AUTO_WAIT_FOR_IDLE: // boolean wait?
          rob.setAutoWaitForIdle((Boolean) arguments[0]);
          break;
        case WAIT_FOR_IDLE:
          rob.waitForIdle();
          break;
      }
    }
  }