| Author |
Making a mouse click in Java?
|
Alex Richards
Greenhorn
Joined: Mar 07, 2011
Posts: 9
|
|
Hi, I've been trying to find a way to make a program in NetBeans IDE that can make your mouse click.
Does anyone have any idea on how I could go about coding this?
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10892
|
|
Alex Richards wrote:Hi, I've been trying to find a way to make a program in NetBeans IDE that can make your mouse click.
Does anyone have any idea on how I could go about coding this?
I can read that two ways:
I wish to make NetBeans behave as though a mouse had just been clicked within the IDEI wish to emulate mouse clicks in some other (unnamed) environment
Can you make your question a little clearer?
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10892
|
|
(I can also read this as you want to have my mouse click, in which case: stay away from my computer! )
|
 |
Alex Richards
Greenhorn
Joined: Mar 07, 2011
Posts: 9
|
|
I would like to write a program that simulates a mouse being clicked. (In other words, I'd like to be away from the computer while the program makes my mouse click ).
I understand how I could write a loop to continuously make the mouse click, but I'm unsure of the code I would need to add in that loop to make the cursor simulate a mouse left-click.
|
 |
Alex Richards
Greenhorn
Joined: Mar 07, 2011
Posts: 9
|
|
And yes, I'd like it to be able to continue running, even if I had a different window open.
(For example, I'd like to be able to open up the internet browser and have the mouse still continually be clicking.)
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12951
|
|
|
I think you can do this with the class java.awt.Robot - look it up in the documentation.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: Making a mouse click in Java?
|
|
|