Robot Class

Ads

 
 
 

Share on Google+Share on Google+

Harshu
Robot Class
1 Answer(s)      7 years ago
Posted in : JSP-Servlet
print.jsp

<[email protected] import="java.awt.*"%>
<[email protected] import java.awt.Robot;"%>
<[email protected] import java.awt.event.KeyEvent; "%>
<[email protected] import java.io.File;"%>
<[email protected] 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.
Ads
View Answers

May 12, 2010 at 11:12 AM


Hi Friend,

We have modified your code:

<[email protected] import="java.awt.*"%>
<[email protected] import=" java.awt.Robot"%>
<[email protected] import= "java.awt.event.KeyEvent"%>
<[email protected] import=" java.io.File"%>
<[email protected] 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

Ads









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... provide the class Robot. It gives the java program much power. It can perform all
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
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  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
Super class of an Exception class
Super class of an Exception class  hello,,, What is super class of an Exception class?   hii,, the super class of an exception is throwable class. and the super class of an throwable class is the object class
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
Explain final class, abstract class and super class.
Explain final class, abstract class and super class.  Explain final class, abstract class and super class.   Explain final class, abstract class and super class. A final class cannot be extended. A final class
class loaders
class loaders   Explain static and dynamic class loaders
class file
class file  How to create class file in jsf easily
.class and .tld
.class and .tld  how to create .class and .tld file
inner class
inner class  what is mean by inner class   Inner class is a non-static class which is defined inside another class
Node class
Node class   hii, What is a node class?   hello, A node class is a class that has added new services or functionality beyond the services inherited from its base class
Matrix Class
Matrix Class   A class to manage matrices and add them. Create in the driver class two objects of it and use the add method
Matrix Class
Matrix Class   A class to manage matrices and add them. Create in the driver class two objects of it and use the add method
wrapper class
wrapper class  list wrapper class methods
printstrim class
printstrim class  discribe PrintStream class
Abstract class
Abstract class  what is an Abstract class
singleton class
singleton class  What is singleton class
Locale class
Locale class  What is the Locale class
Java class
Java class  What is the purpose of the Runtime class
lock on a class
lock on a class  hello, Can a lock be acquired on a class?   hiii,, Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object
wrapper class
wrapper class  wrapper class methods
printstrim class
printstrim class  discribe PrintStream class
Abstract class
Abstract class  Can an abstract class be final
immutable class
immutable class  How to make a class immutable
objective c extending a class with a class
objective c extending a class with a class  I need an example for extending a class with a class in objective c. thanks
objective c extending a class with a class
objective c extending a class with a class  I need an example for extending a class with a class in objective c. thanks
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads