Using Robot in Java


java.awt.Robot is a best robot class which is mainly used to create a simulation software.Due to this robot class you can automatically enable mouse and keyboard event from java code itself.Following program helps us to invoke some basic stuff to get a picture about how to implement robot in java.
// Comment
package com.sabari;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
public class simplerobot {
 

 public static void main(String[] args) {
 try {

 Robot robot = new Robot();
 
 robot.delay(1000);
 robot.keyPress(KeyEvent.VK_J);
 robot.keyPress(KeyEvent.VK_A);
 robot.keyPress(KeyEvent.VK_V);
 robot.keyPress(KeyEvent.VK_A);
 robot.keyPress(KeyEvent.VK_SPACE);
 robot.keyPress(KeyEvent.VK_2);


 } catch (AWTException e) {
 e.printStackTrace();
 }
 }
 } 



Output Window 

In order to run the program first you have to open notepad or word pad .Then you can easily Study the implementation workflow process of Robot.
raja P Web Developer

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...