1 / 12

Robot

Robot. M.C. Juan Carlos Olivares Rojas. Introducción. La clase java.awt.Robot permite definir un objeto que puede realizar acciones de manera automatizada sobre la interfaz gráfica del sistema.

arama
Télécharger la présentation

Robot

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Robot M.C. Juan Carlos Olivares Rojas

  2. Introducción • La clase java.awt.Robot permite definir un objeto que puede realizar acciones de manera automatizada sobre la interfaz gráfica del sistema. • Cuenta en general con métodos para mover el ratón, presionar botones del ratón, presionar teclas, capturar imágenes, entre otras funcionalidades.

  3. Ejemplo import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; public class Aplicacion {     public static void main (String args []) {       new Aplicacion();    }    

  4. Ejemplo Aplicacion() {        try {           Robot robot = new Robot();           // Simula un click con el ratón           robot.mousePress(InputEvent.BUTTON1_MASK);            robot.mouseRelease(InputEvent.BUTTON1_MASK);           // Simula presionar una tecla          

  5. Ejemplo robot.keyPress(KeyEvent.VK_O);           robot.keyRelease(KeyEvent.VK_O);        } catch (AWTException e) {            e.printStackTrace();   }     } }

  6. API • La clase cuenta con dos constructores: • Robot() sin argumentos crea un objeto que opera en toda la pantalla. • Robot(GraphicsDevice screen) Construye un objeto Robot en las coordenadas indicadas. • A continuación se describe cada uno de los métodos de la clase.

  7. API • java.awt.image.BufferedImage createScreenCapture(Rectangle s) Crea una imagen de las coordenadas indicadas.   • void delay(int ms) El objeto se duerme un tiempo especificado de ms milisegundos.   • int getAutoDelay() Obtiene el tiempo en que el Robot se está durmiendo.  

  8. API • Color getPixelColor(int x, int y) Reegresa el color del punto señalado.   • boolean isAutowaitForIdle() Checa si el Robot ejecuta waitForIdle() después de un evento.   • void keyPress(int keycode) Presiona una tecla.  

  9. API • void keyRelease(int keycode) Libera una tecla.   • void mouseMove(int x, int y) Mueve el puntero del ratón a las coordenadas indicadas.   • void mousePress(int buttons) Presiona uno o más botones del ratón.  

  10. API • void mouseRelease(int buttons) Ocurre cuando se libera un botón del ratón.   • void mouseWheel(int wheelAmt) Ocurre cuando gira la rueda del ratón.   • void setAutoDelay(int ms) Configura el tiempo de retardo que existe entre cada evento del Robot.

  11. API • void setAutowaitForIdle(boolean isOn) Configura el tiempo en que el Robot ejecuta un waitForIdle().   • java.lang.String toString() Convierte el Robot en una cadena de texto.   • void waitForIdle() Espera a que todos los eventos de la cola de eventos hayan sido despacahdos.

  12. ¿Preguntas, dudas y comentarios?

More Related