Best viewed in 1024 X 800 resolution... Leave a comment if u like an article...
Google
 
Web tezcols.blogspot.com

Wednesday, July 12, 2006

The Java Robot....

hav u ever heard abt this...

'Controlling a computer with a java program....'

Is that possible... ?

This is what we do with the great Robot class in java...

Try out the program given below...

u need not install any software other than java...

I designed the following program on Windows 2000 Professional with a screen resolution of 1024 x 768 pixels...

U may need to change the coordinate values in the following program if u are using 800 x 600 pixels resolution...

import java.awt.Robot;
import java.awt.event.InputEvent;



/**
* @author Tez K N V
* A program that clicks Start button in windows without user interaction..
*/

public class Robo {

/**
* magic is an object of type java.awt.Robot
*/
Robot magic=null;
public Robo() {
try{
magic=new Robot();
/**
* The next two lines move the mouse to the specified coordinates on the screen...
* and presses the mouse button to click the start button...
* */
magic.mouseMove(15,755);
magic.mousePress(InputEvent.BUTTON1_MASK);
}catch(Exception e){
e.printStackTrace();
}

}

public static void main(String[] args) {
new Robo();
}
}

Not just moving and clicking... u can also type with ur robot.. u can capture ur desktop...


Extension of this concept makes Remote Desktop Sharing possible... (Accessing the desktop of another computer...)

If u need any help.... feel free to ask me...

bye...

tezcols






Labels:

2 Comments:

Anonymous Anonymous said...

Hi,

I read your article java robot.Is that classes are in swing package also.Because i heared that VNC viewer has been written in Java swings.Its a desktop sharing tool.Can you send me more details about this.

3:22 PM  
Blogger Tez said...

yeah
i know vnc...
Robot class will be available in Abstract Windowing Toolkit (AWT). Swing is just used to design the front-end.There is nothing for a robot to do with swing.

10:46 AM  

Post a Comment

<< Home