Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

simulate mousclick

Thread view: 
Tomba - 06 Jun 2006 12:10 GMT
Hi,

I'm wondering if it would be possible to write a program that actually
performs a mouseclick on a given location.

So for instance, I want to perform a mouseclick on my screen (thus on
the program that is currently fills the screen) on position 200,200.

Note that it's not clicking in the java program window, but it should
work anywhere on the screen, the same as actually clicking with the
mouse yourself.

Anyone have an idea?

Thanks
JScoobyCed - 06 Jun 2006 13:03 GMT
> Hi,
>
[quoted text clipped - 11 lines]
>
> Thanks

<code>
import javax.awt.Robot;

public class RobotTest {

public static void main(String[] arg) {
 Robot robot = new Robot();
 robot.mouseMove(200,200);
 robot.mousePress(InputEvent.BUTTON1_MASK);
 robot.mouseRelease(InputEvent.BUTTON1_MASK);
 }
}
</code>

Signature

JSC



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.