FirstName LastName FirstName LastName - 4 months ago 11
Java Question

Want to create mouse clicks on a window with java

I want to create java code which will stimulate a mouse click on any window of a windows OS application - eg browser, word etc.

Can someone suggest how I can begin ? I don't know which API's are needed for this.
I also need to know if this is a very complex task and will require more than just
core concepts of Java.

Thanks in advance.

Answer

The class you would want to use for this task is the Robot class: http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html

It may require more knowledge than the core concepts (depending on what you consider core), but Java is a good language to deal with this kind of thing.

Depending on what you seek to do with this knowledge, this may end up a very complex task. For example, if you sought to click on a specific button on the screen, you would need some way to analyze the screen (a very hard task). If you know where every button is already, you just move to the x, y location and cause a click to occur.

Comments