?
Solved

Fake Mouse Event Generation

Posted on 2003-03-14
8
Medium Priority
?
369 Views
Last Modified: 2008-02-26
hello,
i would like to write a program in JAVA that generates mouse events.. for example
it should move the cursor or click on an icon... all this automatically!!
can you write a simple example or tell me wich class to use?
thanks very much!!
0
Comment
Question by:nur_ismail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 8135485
0
 
LVL 9

Expert Comment

by:Ovi
ID: 8135773
package tests.awt;

import java.awt.AWTException;
import java.awt.Robot;

/**
 * @author ovi
 */
public class RobotDemo {

     public static void main(String[] args) {
          try {
               Robot robot = new Robot();
               int i = 0;
               while(i < 50) {
                    int x = (int) Math.round(Math.random() * 1000);
                    int y = (int) Math.round(Math.random() * 1000);
                    robot.mouseMove(x, y);
                    robot.delay(500);
                    i++;
               }
          } catch (AWTException e) {
               e.printStackTrace();
          }
     }
}
0
 

Author Comment

by:nur_ismail
ID: 8142265
thanks a lot..
but with the class robot i can't generate the mouse click
or the double click on any point of the screen!!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:nur_ismail
ID: 8142271
what i really need is a method to post events on the AWT queue!
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 800 total points
ID: 8142289
Try getting the event queue

EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue();
 

and then calling q.postEvent(x)
0
 

Expert Comment

by:CleanupPing
ID: 9058693
nur_ismail:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 35

Expert Comment

by:girionis
ID: 9762819
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to CEHJ

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question