Java and interaction with system mouse events

Advertisement

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.

Advertisement

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

November 30, -0001

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

Cut and Paste with Mighty Mouse?

I just bought a new mighty mouse and I cannot figure out how to cut and past using the mouse. Do I right click, double click on the highlighted word or left click? Also, how do I drag highlighted phrases? Thanks! mighty mouse Mac OS X (10.4)if you go

How to detect only single click and not double-click mouse events in Swing?

Hi, In my application, I want to implement a functionality only for single click. But problem is on double click, first i can see a single click and then double click. i.e e.getCount() return 1 and then 2 for double click. I want to avoid this situat

Java and the embedded system

Dear readers, I'm having a project in mind about developing an embedded system and I want to use the flexibility of java to implement it . I'm new to the embedded system, so please try to guide me and recomend me websites as much as you can. Thanks i

!!! Statements of Logic Deleting Files and messing with System are True !!!

This morning I answered some guys post about Logic deleting everything in the same level as the project folder under certain circumstances. I Tried trouble shooting for him but could not recreate it. Then this happened to me today: When working in Lo

Best way to display and interact with a tree

I am trying to create an interface that is similar to the interface on this website for the skill tree:http://www.pathofexile.com/passive-skill-tree. What is the best way to go about doing this and have the same or similar user interaction. ie. you c

Java and Reflection with java 1.5.06b

My java programs no longer run after i upgraded to Java 1.5.06b. They rely heavily on java reflection, since the classes are loaded and instanced dynamically at runtime. I have set my classpath in my .tcshrc and it works on my linux/solaris boxes, bu

Dynamic display and interaction with UI components...Need help!!

hi I want to create forms which asks users to enter data in some fields/GUI components. If i call these field one "group" then i have to display this group of components as many times as may be required (based on some other calculation). How can

Is there any other way to view and interact with notes except through Mail?

Using the iPad I really like using notes as a stand-alone app. Is there a way to do this in OSX or can I only access my notes through Mail? If only through mail, can they live someplace other than my inbox? ThanksTo not have them in your inbox, go to

Interacting with processor

Okay, so I'm curious about how to use Java to interact with the processor like you would with C or C++. For example, what if I wanted to interact with a process or write a software driver using Java.write a software driver using JavaYou can't.Well I

Mac java - no mouse event

I am having trouble with my app where when you are at the login screen and you enter your login name, then click on the password text field the focus will not go there but remains on the user name field. You can tab ok to the password field. Has anyo

Interacting with Operating System

Does anyone know if Java has the ability to interact with the OS to filter print jobs and IO operations initiated from other applications? I need to write an application that acts as as a filter to prevent Netscape from printing and/or saving files.

Interacting with client system using Applet

Hi, I want to interact with client system and access files on his system using applet,could u suggest the way to do it or any other siurce where I can find this information. It's very urgent,pl reply soon thanqhi, These steps will get your applet sig

Interacting with Powershell from Java

Hi, I'm trying to run a Java application which creates a new powershell process on startup and then later on interacts with it multiple times. Calling powershell.exe and have it execute a single command and return the output works fine for me. The pr

I deleted duplicate files with MacKeeper and now my firefox only shows text. I have reinstalled firefox, java, and checked all of my settings. Any ideas? Safari works fine.

I deleted duplicate files with MacKeeper and now my firefox only shows text. I have reinstalled firefox, java, and checked all of my settings. Any ideas? Safari works fine.I opened iCal back up, all the dates were blank, so i started to type events i

Is there any event in windows universal app (wp8.1&win8.1) that fires when screen locked and unlocked with in the app?

Hi All, Is there any event in windows universal app (wp8.1&win8.1) that fires when screen locked and unlocked with in the app Right now, I am using this below mentioned event Window.Current.VisibilityChanged += CurrentWindow_VisibilityChanged;, but i

After several time installed CS6 and a clean Windows 8.1 bridge still pause after selecting a picture or right click with button mouse.

My bridge pause all the time. I have to wait 30 seconds after selecting a picture or click the right button of the mouse. I have installed a new windows 8.1, and a fresh CD6. But still these problems in Bridge. No problems in Photoshop. What to doWha

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 doubleclickMaybe post s

RichEditableText with embedded images does not handle mouse events reliably

I'm using Flash Builder "Burrito".  downloaded a couple of weeks ago.  Flash Player 10.1.85.3 debug version. I have the following MXML object: <s:Scroller width="100%" height="100%" xmlns:fx="http://ns.adobe.com/mxml/

Interact with exe in java

Hi! I got a old exe file, that no more maintain by any team. Unfortunately, requirement has it that I need to run this exe, do some interaction, such as "enter" and "wait" and "input value", get "value" And it has t