Robot Class

Robot Class

print.jsp

<%@page import="java.awt.*"%>
<%@page import java.awt.Robot;"%>
<%@page import java.awt.event.KeyEvent; "%>
<%@page import java.io.File;"%>
<%@page import javax.swing.filechooser.*;"%>

<%! Robot robot;
//JFileChooser chooser;
%>

<%
try
{
robot = new Robot();
//chooser = new JFileChooser();
}
catch(Exception e){}
%>

<%!

void move()
{

try{


/*File obj = new File("Invoice.xls");
chooser.setSelectedFile(obj);
chooser.ensureFileIsVisible(obj);
Boolean b = chooser.accept(obj);
System.out.println(b);

if(b)
{
int x = chooser.APPROVE_OPTION;
System.out.println("Hi");
}*/
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "C:\\excel\\createCell.xls");

robot.delay(5000);
out.println("Hey");
robot.keyPress(KeyEvent.VK_CONTROL);

robot.keyPress(KeyEvent.VK_P);

robot.keyRelease(KeyEvent.VK_CONTROL);

robot.keyRelease(KeyEvent.VK_P);

}
catch(Exception e1)
{
e1.printStackTrace();
}

}

%>

<%
out.println("<input type='button' onclick='"+move()+"'>");

%>


//robot.delay(3000);
//robot.mouseMove(500,500);
//<% out.println("<BR/><FONT>MOVED FIRST!</FONT>"); %>
//robot.delay(3000);
//robot.mouseMove(100,100);
//<% out.println("<BR/><FONT>MOVED TWICE!</FONT>"); %>


//int y = 1;
//while(y==1)
//{
//Robot robot = new Robot();
// Creates the delay of 5 sec so that you can open notepad before
// Robot start writting


Hello Sir in this code its giving me error that print.jsp(1,15) equal symbol expected i dont know wdy this error is coming but please help out of this problem and it should give automatic printing option???

Please reply me sir as soon as possible??

Thank you sir.
View Answers

May 12, 2010 at 11:12 AM

Hi Friend,

We have modified your code:

<%@page import="java.awt.*"%>
<%@page import=" java.awt.Robot"%>
<%@page import= "java.awt.event.KeyEvent"%>
<%@page import=" java.io.File"%>
<%@page import=" javax.swing.filechooser.*"%>

<%! Robot robot;
//JFileChooser chooser;
%>
<%
try{
robot = new Robot();
//chooser = new JFileChooser();
}
catch(Exception e){}
%>
<%!
void move(){
try{
/*File obj = new File("Invoice.xls");
chooser.setSelectedFile(obj);
chooser.ensureFileIsVisible(obj);
Boolean b = chooser.accept(obj);
System.out.println(b);

if(b){
int x = chooser.APPROVE_OPTION;
System.out.println("Hi");
}*/
//Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "C:\\excel\\createCell.xls");
robot.delay(5000);
System.out.println("Hey");
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_P);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_P);
}
catch(Exception e1){
e1.printStackTrace();
}
}
%>
<script>
function hello(){
<%
move();
%>
}
</script>
<input type='button' onclick="hello();">
<%//robot.delay(3000);
//robot.mouseMove(500,500);
// out.println("<BR/><FONT>MOVED FIRST!</FONT>");
//robot.delay(3000);
//robot.mouseMove(100,100);
//out.println("<BR/><FONT>MOVED TWICE!</FONT>");


//int y = 1;
//while(y==1)
//{
//Robot robot = new Robot();
// Creates the delay of 5 sec so that you can open notepad before
// Robot start writting
%>

Thanks









Related Tutorials/Questions & Answers:
robot class
robot class  please send me uses of robot class and some examples using robot class
robot class
robot class  i also want the uses of robot classes its applications in the programming. where exactly robot class is useful. why is it necessary... java.awt.* has provide the class Robot. It gives the java program much power. It can
Advertisements
Robot class - Java Beginners
Robot class  hi!!! wenever i execute this code i get the error...! import java.lang.*; import java.awt.*; public class Robot04{ public...{ Robot robot = new Robot(); robot.mouseMove(1005,10); robot.delay(2000
Robot Class - JSP-Servlet
Robot Class  print.jsp...); // //int y = 1; //while(y==1) //{ //Robot robot = new Robot... // Robot start writting Hello Sir in this code its giving me error
class
class  Is a class a subclass of itself
class
is a class to represent a country in medal tally. It has an attribute of country... medals. In this class, you should also define constructors, and assessor, mutator methods. Task 2 MedalTally.java is a class to model a medal tally, containing
Class
Class, Object and Methods       Class : Whatever we can see in this world all the things... is termed as a class. All the objects are direct interacted with its class
ModuleNotFoundError: No module named 'robot'
ModuleNotFoundError: No module named 'robot'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'robot' How to remove the ModuleNotFoundError: No module named 'robot'
ModuleNotFoundError: No module named 'cord-robot'
ModuleNotFoundError: No module named 'cord-robot'  Hi, My Python... 'cord-robot' How to remove the ModuleNotFoundError: No module named 'cord-robot' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'cord-robot'
ModuleNotFoundError: No module named 'cord-robot'  Hi, My Python... 'cord-robot' How to remove the ModuleNotFoundError: No module named 'cord-robot' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'dingtalk-robot'
ModuleNotFoundError: No module named 'dingtalk-robot'  Hi, My... named 'dingtalk-robot' How to remove the ModuleNotFoundError: No module named 'dingtalk-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pyramid_robot'
ModuleNotFoundError: No module named 'pyramid_robot'  Hi, My... 'pyramid_robot' How to remove the ModuleNotFoundError: No module named 'pyramid_robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'py_robot'
ModuleNotFoundError: No module named 'py_robot'  Hi, My Python..._robot' How to remove the ModuleNotFoundError: No module named 'py_robot... to install padas library. You can install py_robot python with following
ModuleNotFoundError: No module named 'Robot-AppEyes'
ModuleNotFoundError: No module named 'Robot-AppEyes'  Hi, My... 'Robot-AppEyes' How to remove the ModuleNotFoundError: No module named 'Robot-AppEyes' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-blocks'
ModuleNotFoundError: No module named 'robot-blocks'  Hi, My Python... 'robot-blocks' How to remove the ModuleNotFoundError: No module named 'robot-blocks' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-cli'
ModuleNotFoundError: No module named 'robot-cli'  Hi, My Python... 'robot-cli' How to remove the ModuleNotFoundError: No module named 'robot... have to install padas library. You can install robot-cli python with following
ModuleNotFoundError: No module named 'robot-commands'
ModuleNotFoundError: No module named 'robot-commands'  Hi, My... named 'robot-commands' How to remove the ModuleNotFoundError: No module named 'robot-commands' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-detect'
ModuleNotFoundError: No module named 'robot-detect'  Hi, My Python... 'robot-detect' How to remove the ModuleNotFoundError: No module named 'robot-detect' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-executor'
ModuleNotFoundError: No module named 'robot-executor'  Hi, My... named 'robot-executor' How to remove the ModuleNotFoundError: No module named 'robot-executor' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-grpc'
ModuleNotFoundError: No module named 'robot-grpc'  Hi, My Python... 'robot-grpc' How to remove the ModuleNotFoundError: No module named 'robot-grpc' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'robot-nps'
ModuleNotFoundError: No module named 'robot-nps'  Hi, My Python... 'robot-nps' How to remove the ModuleNotFoundError: No module named 'robot... have to install padas library. You can install robot-nps python with following
ModuleNotFoundError: No module named 'robot-spline'
ModuleNotFoundError: No module named 'robot-spline'  Hi, My Python... 'robot-spline' How to remove the ModuleNotFoundError: No module named 'robot-spline' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-tesults'
ModuleNotFoundError: No module named 'robot-tesults'  Hi, My... 'robot-tesults' How to remove the ModuleNotFoundError: No module named 'robot-tesults' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'scikit-robot'
ModuleNotFoundError: No module named 'scikit-robot'  Hi, My Python... 'scikit-robot' How to remove the ModuleNotFoundError: No module named 'scikit-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'selenium-robot'
ModuleNotFoundError: No module named 'selenium-robot'  Hi, My... named 'selenium-robot' How to remove the ModuleNotFoundError: No module named 'selenium-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'tabelog-robot'
ModuleNotFoundError: No module named 'tabelog-robot'  Hi, My... 'tabelog-robot' How to remove the ModuleNotFoundError: No module named 'tabelog-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'weallcode-robot'
ModuleNotFoundError: No module named 'weallcode-robot'  Hi, My... named 'weallcode-robot' How to remove the ModuleNotFoundError: No module named 'weallcode-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'behavior_robot'
ModuleNotFoundError: No module named 'behavior_robot'  Hi, My... named 'behavior_robot' How to remove the ModuleNotFoundError: No module named 'behavior_robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ciag-robot'
ModuleNotFoundError: No module named 'ciag-robot'  Hi, My Python... 'ciag-robot' How to remove the ModuleNotFoundError: No module named 'ciag-robot' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'cloudwatch-robot'
ModuleNotFoundError: No module named 'cloudwatch-robot'  Hi, My... named 'cloudwatch-robot' How to remove the ModuleNotFoundError: No module named 'cloudwatch-robot' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'cord-robot'
ModuleNotFoundError: No module named 'cord-robot'  Hi, My Python... 'cord-robot' How to remove the ModuleNotFoundError: No module named 'cord-robot' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'dingtalk-robot'
ModuleNotFoundError: No module named 'dingtalk-robot'  Hi, My... named 'dingtalk-robot' How to remove the ModuleNotFoundError: No module named 'dingtalk-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'flylog-robot'
ModuleNotFoundError: No module named 'flylog-robot'  Hi, My Python... 'flylog-robot' How to remove the ModuleNotFoundError: No module named 'flylog-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cord-robot'
ModuleNotFoundError: No module named 'cord-robot'  Hi, My Python... 'cord-robot' How to remove the ModuleNotFoundError: No module named 'cord-robot' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'M_robot'
ModuleNotFoundError: No module named 'M_robot'  Hi, My Python..._robot' How to remove the ModuleNotFoundError: No module named 'M_robot... to install padas library. You can install M_robot python with following command
ModuleNotFoundError: No module named 'py_robot'
ModuleNotFoundError: No module named 'py_robot'  Hi, My Python..._robot' How to remove the ModuleNotFoundError: No module named 'py_robot... to install padas library. You can install py_robot python with following
ModuleNotFoundError: No module named 'robot-brains'
ModuleNotFoundError: No module named 'robot-brains'  Hi, My Python... 'robot-brains' How to remove the ModuleNotFoundError: No module named 'robot-brains' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-controller'
ModuleNotFoundError: No module named 'robot-controller'  Hi, My... named 'robot-controller' How to remove the ModuleNotFoundError: No module named 'robot-controller' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'robot-detection'
ModuleNotFoundError: No module named 'robot-detection'  Hi, My... named 'robot-detection' How to remove the ModuleNotFoundError: No module named 'robot-detection' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-jsonschemalibrary'
ModuleNotFoundError: No module named 'robot-jsonschemalibrary'  Hi...: No module named 'robot-jsonschemalibrary' How to remove the ModuleNotFoundError: No module named 'robot-jsonschemalibrary' error? Thanks   
ModuleNotFoundError: No module named 'robot-opentmi'
ModuleNotFoundError: No module named 'robot-opentmi'  Hi, My... 'robot-opentmi' How to remove the ModuleNotFoundError: No module named 'robot-opentmi' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'robot-testrail-python2'
ModuleNotFoundError: No module named 'robot-testrail-python2'  Hi...: No module named 'robot-testrail-python2' How to remove the ModuleNotFoundError: No module named 'robot-testrail-python2' error? Thanks   Hi
ModuleNotFoundError: No module named 'scikit-robot'
ModuleNotFoundError: No module named 'scikit-robot'  Hi, My Python... 'scikit-robot' How to remove the ModuleNotFoundError: No module named 'scikit-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'telebaka-robot'
ModuleNotFoundError: No module named 'telebaka-robot'  Hi, My... named 'telebaka-robot' How to remove the ModuleNotFoundError: No module named 'telebaka-robot' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'timi-robot'
ModuleNotFoundError: No module named 'timi-robot'  Hi, My Python... 'timi-robot' How to remove the ModuleNotFoundError: No module named 'timi-robot' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'alva-robot'
ModuleNotFoundError: No module named 'alva-robot'  Hi, My Python... 'alva-robot' How to remove the ModuleNotFoundError: No module named 'alva-robot' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'ddm-robot'
ModuleNotFoundError: No module named 'ddm-robot'  Hi, My Python... 'ddm-robot' How to remove the ModuleNotFoundError: No module named 'ddm-robot' error? Thanks   Hi, In your python environment you
Super class of an Exception class
Super class of an Exception class  hello,,, What is super class of an Exception class?   hii,,ADS_TO_REPLACE_1 the super class of an exception is throwable class. and the super class of an throwable class
Web robot to find the best deal
Web robot to find the best deal  Build a Web robot that looks at certain retailers to find the best deal. For example, if you want to buy a textbook then you can give to the robot. The robot would visit the famous online book
Class
Class       This section explores the concept of a class in reference to object oriented programming techniques. A class defines the properties of  objects and methods used

Ads