Capturing desktop mouse events in java

hi,
i want to capture mouse events running outside JVM,how do i get
it.example if click on some application for opening it.how will i get it in my java prog.
bye

There is an example,it works well .
import java.awt.*;
public class CatchMouse {
     public static void main(String[] args) {
          int limit=10;
          Point mp=null;
          for(int i=0;i<limit;i++){
               mp=MouseInfo.getPointerInfo().getLocation();
               System.out.println(mp.x+","+mp.y);
               try{
                    Thread.sleep(500);
               }catch(InterruptedException ie){
}I hope it can help you.

Similar Messages

  • How to handle doubleclick mouse event in java

    i want to handle double click mouse event in java
    i use getClickCount() function
    but i want that on onetime click show othere windows
    and on doubleclick show diif. window
    but problem is that onetime is occuer always if u click doubleclick

    Maybe post some code so we can see what, if anything, you are doing wrong.
    Examing the results of a call to getClickCount() is the correct way to detect a double click.

  • Capture desktop key event to control my screen capture app

    I want to write a screen capture program to capture screen when I am playing fullscreen game or other desktop window application. But the java screen capture program can only receive key or mouse event when it is focused. So how do I capture key event when I am focusing other app or fullscreen app?
    Do I have to use JNI and call some OS specific API. My target OS is WinXP. Help or suggestions are appreciated!!

    Hi All,
    I was wondering if there is a way to capture the top-most
    window or dialog box. This is something that will
    generally be running outside of the JVM....We,
    as programmers, need a Rectangle instance that describes the area
    of interest to be captured (i.e., location and size).
    Thus, a routine that interfaces to the Native windowing system (Toolkit?)
    might look something like:
    Rectangle rect = tk.getRectangleForTopMostComponent();
    Does anything like this exist?
    Thanks!
    - DocJava

  • How to capture Wnidows(OS) event from Java program

    Hi,
    I am developing one application , in that if the user didn't do any thing in 15 mins,i need to log out from my application(not windows).Here i need to check Java event as weel as windows(OS) events also.Any one knows how to capture the OS events??

    I want to know the status of mouse and keyboard(Windows 2000).If the status of the mosue or keyboard doesn't change from 15min i need to log of the java application.

  • Capturing global mouse events ?

    Is it possible to capture mouse event generated outside the application as well, as if the java app is running and the user opens a explorer and clicks at something, how can i capture that action ?

    not with pure Java. JNI with native code

  • Capturing Blocked Mouse Events

    Does anyone know of a way for a displayObject to receive
    mouse events, as the target of that event (MOUSE_OVER, MOUSE_DOWN,
    etc) if it happens to be overlapped by another display object. I've
    tried setting the .mouseEnabled of the obscuring displayObject to
    false, as well as setting its .mouseChildren to false, but no joy
    there. Is there a way for the obscuring displayObject to pass the
    event along to display objects that happen to be beneath it?
    Is there a trick that I don't know of, or is this simply not
    possible?
    -thanks for taking the time to read this post.
    -arthur

    not with pure Java. JNI with native code

  • Is it possible to trace the mouse event using java script in indesign cs3?-request urgent

    Hi friends,
    am writing js for indesign cs2, i want to know the things whether it is possible for tracing the curse position in indesign application using javascript? i need it to know for both cs2 and cs3
    thanks in advance
    by
    subha

    to Subha:
    I definitely do not know enough to answer your question.
    But on June 14, 2007, Dave Saunders started a topic
    (this forum) titled "Am I making progress".
    Posts 23 and 32 there could be helpful, but I may
    have misunderstood your phrase "tracing the
    cursor position".
    Roger Purves

  • Capturing Mouse Events on Desktop??

    Is there a way to capture mouse events on the Desktop. I would like to be notified of the Mouse Location and Click Events for the entire Desktop.

    Mouse Events may only be capture INSIDE the java application frame. SO, if your desktop is not a java component, you will not be able to capture the events.
    However, you could maybe use JNI to use native methods so as to get the location of the mouse...
    vincent

  • Traping all Events with Java App

    Is it possible to trap all mouse event from Java code even when the java app is not in focus? Lets say a VB app is running and then Java needs to know that that VB app has been clicked?
    ANy useful tip on this?

    Is it possible to trap all mouse event from Java code
    even when the java app is not in focus? No.
    You will have to do this with native code.

  • Handling mouse events anywhere

    Hi,
    We have built an application with a Swing GUI and for automation and testing we would like to record all keyboard and mouse events to be able to play them afterwards.
    The keyboard events can be recorded easily with a KeyboardFocusManager but for the mouse events I still need a solution.
    The GUI consists of a JFrame containing several JPanels. When I add a MouseListener on the JFrame, its mousePressed and mouseReleased events are not called everytime I click somewhere on the frame. For example, when I click on a button inside one of the JPanels, the mouse event methods of the frame are not executed.
    Can somebody tell me how I can easily capture all mouse events in the GUI without adding MouseListeners in every JPanel??
    Thanks in advance...

    I know how to use the Robot class, that's not really the issue.
    What we are doing actually is writing keyboard and mouse events into a file.
    Afterwards we use the Robot class to playback the events in the file. This is no problem, I just don't know how I can easily intercept ALL mouse events in the GUI without adding mouseListeners in each component in the GUI.

  • Capture All Mouse and Keyboard events even if java window NOT in FOCUS

    Hi All,
    Is this possible to capture all mouse and keyboard events even if java window is not in focus or is minimized. This java program should cature each and every event from the user once the program is started. Any help in this regard is appreciated!
    Thanks&Regards
    Sam

    I don't think you can. (without JNI)

  • Capturing Mouse Events On MediaPlayer

    Hi,
    I have created a video conference application based on JMF. In this application I am using MediaPlayer control to play the rtp stream. Now I want to capture Mouse Events like MouseClick and MouseMove. But sorry to say that I am not getting any event on MediaPlayer control. I have tried this on other controls and successful. Can anybody tells me how to capture mouse events on MediaPlayer.
    --ibrar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Mouse Events may only be capture INSIDE the java application frame. SO, if your desktop is not a java component, you will not be able to capture the events.
    However, you could maybe use JNI to use native methods so as to get the location of the mouse...
    vincent

  • Mouse event not working on JTable in JAVA 1.4.2

    mouse event is not recognised on empty table when using with java 1.4.2. Please specify if there is any chnge done for mouse event capture for table from java 1.3.1 to java 1.4.2.
    since mouse events are working fine for JTableHeader.
    if anybody have an idea please let me know.

    Hi
    JTable is there on JPanel . same code is working in JAVA 1.3.1
    actually its a bug in java 1.4.2 ( ref. bug_id=4940522 )
    here is the code reference..
    public class TableEditor extends JPanel
    �implements ListSelectionListener, Selector, Editor
    private JTable�myTable;
    private JPopupMenu myPopup;
    private Vector�myActions;
    private Vector�myListeners;

    public TableEditor(String anAssociation, Editor anEditor, int type)
    super(new GridLayout(1,1));

    myListeners = new Vector();
    myActions�= new Vector();
    myPopup�= new JPopupMenu();
    myTable�= new JTable();
    ��
    myTable.getSelectionModel().addListSelectionListener(this);
    myTable.addMouseListener(new MouseAdapter() {
    �public void mouseClicked(MouseEvent me)
    �{
    � if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    � {
    ��// Update actions in case ListSelectionModel are out of sync.
    ��for (int i = 0; i < myActions.size(); i++)
    ��{
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    ���}
    myPopup.show(myTable, me.getX(), me.getY());
    �}
    // Added mouse listener to JTableHeader
    // This is a temporary solution to open popup menu on blank table,
    // as in Java 1.4.2 no mouse event captured on blank table.
    // So for now we will capture the event from the table header.
    JTableHeader myTableHeader = myTable.getTableHeader();
    myTableHeader.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me)
    �{
    if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    // Update actions in case ListSelectionModel are out of sync.
    for (int i = 0; i < myActions.size(); i++)
    ��{
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    ���}
    myPopup.show(me.getComponent(), me.getX(), me.getY());
    � }
    �});
    The solution given is temporary ( adding JTableHeader component)..
    we want to retain the same functionality .. mouse event should get captured on empty table only..

  • Java and interaction with system mouse events

    I would like my Java app to be notified of all Mouse events (primarily clicks is what I am interested in) even when they occur outside the java app or when java app is not the focus. For example the user may be clicking on the File menu of Microsoft Word. I'd like to know that a mouse click occured at x,y coordinate when that happens.
    Can this be done with Java API or is there a need for native code that talks to the OS (Windows and OS X) directly, which should be called with Java Native Interface?
    I would appreciate any pointers in the right direction.

    Hi,
    I'm also trying to find a way of intercepting mouse clicks when they occur outside java components.
    The code for getting the pointer location from the desktop is:
    import java.awt.*;
    public class MouseLocation
         private MouseInfo mInfo;
         private PointerInfo pInfo;
         private Point point = new Point();
         private int buttons = 0;
         private double pointX = 0d;
         private double pointY = 0d;
         private Robot robot;
         public MouseLocation()
              try
              {     robot = new Robot();     }
              catch(Exception e)     {     }
              hasMouse();     
              pointerLocation();
         }//ends constr.
         private void hasMouse()
              buttons = mInfo.getNumberOfButtons();
              if(buttons == -1)
                   System.out.println("No mouse detected.  Program terminated.");     
                   System.exit(0);     
         }//ends hasMouse()
         private void pointerLocation()
              try
                   pInfo = mInfo.getPointerInfo();
                   point = pInfo.getLocation();
                   pointX = point.getX();
                   pointY = point.getY();
                   System.out.println("pointer is at: (" + (int)pointX + ", " + (int)pointY + ")");
                   delay();
              catch(HeadlessException he)     
                   System.out.println((he.toString()) + ".  Program terminated.");     
                   System.exit(1);
              catch(SecurityException se)     
                   System.out.println((se.toString()) + ".  Program terminated.");     
                   System.exit(1);
         }//ends pointerLocation()
         public String getPointerLocation()
         {     return (point.toString());     }//ends getPointerLocation()
         public void delay()
              try
                   robot.delay(6000);     
                   pointerLocation();
              catch(Exception e)     {     }
         }//ends delay()
         public static void main(String[] args)
              MouseLocation ml = new MouseLocation();
         }//ends
    }//ends class MouseLocation

  • How Keyboard & Mouse Events are handled in java?

    Hi
    How Keyboard & Mouse Events are handled in java?
    Kindly brief, how a key typed in the keyboard is sensed and it is entered in JTextField?
    or
    Pls. give me some links.
    Am going to send the events from external device (like keyboard) to OS and from that I need to capture that event in Java Swing?
    Pls. drop in a bit. So that it will be helpfull to me.
    Thanks in advance,
    bee

    Actualy am very much aware of using KeyListener and MouseListener. I am in need of internal details,
    how typing a key in keyboard is captured by KeyListener? How the event is passed to java swing and and it is fired to keylistener.
    Pls. help me.
    Thanks
    bee

Maybe you are looking for

  • Why Doesn't Flash 9 Work in Safari?

    I am a Flash developer and I would like to know when (or if) Safari will ever be capable of playing Flash 9 content. I know there is a way for me to 'hack' Safari with a bug-fix but this is unhelpful because I'm not concerned about my Safari browser

  • Getting Wireless Users onto LAN

    Hello All, We currently purchased 2 AP's and a 2106 WLC and I am having some trouble getting the wireless users to communicate to the network on the other side of the WLC. Here is a very simple diagram on how this is all connected. 3750X L3 Switch --

  • Consume SAP webservices wsdl from Delphi 2007

    am trying to consume SAP webservices from Delphi 2007, but, i was some problems with this task. I used WSDL definition to make the Delphi interface and i´m working with THTTPRIO component to try consume SAP Webservices, but , occurs this error: Conex

  • How to handle optional elements in Simple Transformation

    Greetings! I'm working on an ST that needs to be able to serialize an ABAP itab to XML which may or may not contain certain elements depending on the customer to whom the file is being sent.  Additionally, we receive a file that uses the same schema

  • Reg: How to add Quotation No. in Notification Details.

    Hi Experts, I created a Quotation using BAPI, now I want to assign that Quotation to Notification No.(IW52). That field is in Display mode, So I cant use BDC. I used "BAPI 'BAPI_ALM_NOTIF_DATA_MODIFY"  & 'BAPI_ALM_NOTIF_DATA_ADD' to update the Quotat