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

Similar Messages

  • Display and interact with a vi front panel on remote C++ app

    Hello:
    I am new to LV and need a little advice.  I need to display a LabVIEW VI front panel in my C++ .Net application that users can interact with to view real-time spectrum data.  The C++ app (client) must reside on a separate computer(s) from the VI so that the client can connect from anywhere around the world and interact with the VI. 
    I am not sure about the basic architecture that should accompany a good solution.  We want to use TCP/IP but not DataSocket.  I do not have access to Measurement Studio but I do have access to LabVIEW Professional Development System v 8.2.  Can anyone provide suggestions on what I need to do in order to
    1.  Connect to my TCP server using my C++ client app - I have already written TCP client and server code which communicate but now I need to integrate LV
    2.  Get access to the VI sitting on that server
    3.  Send the VI front panel to the client for display
    4.  Allow the user to modify parameters on the front panel displayed on the C++ client, send those changes back to the server, and refresh the front panel displayed in the C++ client given the new parameters (I would like a real-time display of the spectrum to always be available)
    Is this possible?  Has anyone done this using C++ .NET in VS2005?  Are there examples I can mimic or references that will help direct me?  I have searched and searched through NI's help and found a lot of good stuff but I'm still feeling confused about the best way to utilize LV.
    Thank you in advance!

    One more question ... what if I could use Measurement Studio?  The documentation seems to indicate that it's easy to create network applications and therefore it would be easy for me to re-create our VI's front panel using Measurement Studio components in my C++ app and then simply connect those components to the networked hardware (TCP/IP or DataSocket) that could be located anywhere in the world.
    Depending on what components you are using in your LabVIEW panel, it is probably pretty easy to build a Measurment Studio application to look like a LV panel.
    Given that, you could use network shared variables to move data across the network, no TCP programming necessary -- I think that this is pretty easy to do, but I don't know the specifics about variable programming in that environment.  Also, you will probably need to add some smarts to the server side to make sure that it is reading to and writing from variables in an appropriate manner.
    Question: why can't you just use LabVIEW for the client application also?

  • Scrolling and rightclicking with magic mouse doesnt  work anymore

    Suddenly scrolling and rightclicking with magic mouse doesnt work any more. Left clicking and cursor moving works normal. I have checked the system preferences for the mouse and find nothing strange or unchecked. Any ideas?

    Also tried the universal access thing. Doesnt work.

  • Using java to interact with a website

    I'm looking to build a program that will function as an alternate front end for an online database so that users can perform batched operations. Is there a way to have java navigate and interacte with a website? This would be something a macro would do, except that I need to be able to interact with the desktop, among other things. Also, I'm stuck with internet explorer, as the IT people don't want Firefox on any of the machines, so that excludes the iMacros add on.
    anyone got an idea? thanks

    DrClap wrote:
    Unless you also control the website. However, even in that case I think that web services are superior in the long run to HTML-scraping.Agreed. I was assuming that if the website was one's own, one wouldn't resort to scraping, but you're right, that needs to be stated.

  • I am synching my ipad and iphone with icloud. Events put in calendar go to the iphone, but if i enter an event on the iphone, it does not go to the ipad. What do i do to get this to work both ways?

    I am synching my ipad and iphone with icloud. Events put in calendar on ipad  go to the iphone calendar,, but if i enter an event on the iphone calendar, it does not go to the ipad. What do i do to get this to work both ways?

    OK Vicky, good clues...
    See if this helps...
    Open Keychain Access in Utilities, use Keychain First Aid under the Keychain Menu item, then either check the Password under that item, change it, or delete it and start over. See if there are duplicates, should be one for Incoming & one for Outgoing.
    Resetting your keychain in Mac OS X...
    If Keychain First Aid finds an issue that it cannot repair, or if you do not know your keychain password, you may need to reset your keychain.
    http://support.apple.com/kb/TS1544

  • Is it possible to connect an iPad to a SmartBoard and interact with the iPad on the SmartBoard, like you do on a computer with the Smart-software Notebook on it?

    Is it possible to connect an iPad to a SmartBoard and interact with the iPad on the SmartBoard, like you do on a computer with the Smart-software Notebook on it?

    You can purchase an adapter from apple that uses the monitor cable from the projector, its the same one that is probably connecting either your laptop or school workstation. On the projector control you might need to refresh the source.

  • Homgeneous System Copy with Java and DB2 with database tools.

    Hello,
    we have an single java stack (netweaver 2004s) and tried a system copy with database tools.
    Source System: DP2, dp2adm, db2dp2, sapdp2db
    Target System: SP2, sp2adm, db2sp2, ???
    We followed the documentation "System copy for SAP systems based on sap netweaver 2004s SR1 JAVA. We exported the SDM on the source system made a redirected restore with db tools and tried to install a new target system.
    During the import in the target system using sapinst we get in the
    phase run java migration tool kit the following error message.
    Caused by:
    com.sap.engine.frame.core.configuration.ConfigurationException: Error
    while connecting to DB.
    at
    com.sap.engine.core.configuration.bootstrap.ConfigurationManagerBootstrapImpl.(ConfigurationManagerBootstrapImpl.java:49)
    ... 14 more
    Caused by: com.ibm.db2.jcc.a.SqlException: Connection authorization
    failure occurred. Reason: userid revoked.
    What I didn't understand is, that in the documenation it is mentioned, that you have to use the same java database connect user. But during the installation of the target system (SP2) I cannot change the java database connect user to sapdp2db. I'm only allow to enter sapsp2db. That might then cause the connection problem.
    Regards
    Alexander Türk
    I

    Hi Alexander
    yes , give it a try , but see note
    970518 Hom./Het.System Copy SAP NetWeaver 2004s SR2
    and all other related notes , if it matches your environment .
    Best regards
    dirk

  • Cannot click and drag with bluetooth mouse?

    I have installed bluetooth mouse and works fine but cannot click and drag using the mouse in any applications. will highlight stuff and cursor moves fine but then cannot drag using the mouse. Any ideas?

    I was trying with this code which I got from this website as I am beginner of AS3.
    var images:MovieClip = images_mc;
    var offsetFrame:int = images.currentFrame;
    var offsetX:Number = 0;
    var offsetY:Number = 0;
    var percent:Number = 0;
    images.addEventListener(MouseEvent.MOUSE_DOWN,startDragging);
    images.addEventListener(MouseEvent.MOUSE_UP,stopDragging);
    function startDragging(e:MouseEvent):void
    images.addEventListener(MouseEvent.MOUSE_MOVE,drag);
    offsetX = e.stageX;
    offsetY = e.stageY;
    function stopDragging(e:MouseEvent):void
    images.removeEventListener(MouseEvent.MOUSE_MOVE,drag);
    offsetFrame = images.currentFrame;
    function drag(e:MouseEvent):void
    percent =  (e.stageX - offsetX)/images.width;
    percent =  (e.stageY - offsetY)/images.height;
    var frame:int = Math.round(percent*images.totalFrames) + offsetFrame +1;
    while (frame>images.totalFrames)
      frame -=  images.totalFrames;
    while (frame<=0)
      frame +=  images.totalFrames;
    images.gotoAndStop(frame);
    This has to rotate in top also i.e., I also have images sequence placed with top view also.
    If I use keyboard, it has to work with arrow keys also and also with mouse interactivity.

  • Swipe left and right with magic mouse doesn't work in safari

    Hey there,
    I accidently deleted something in the navigation bar in safari.
    Now when i swipe left and right with my magic mouse, it doesn't go to the previous pages anymore. But the wierd thing is it still works with my magic trackpad.
    And even wierder the swipe left and right of my magic mouse still works in other programs.
    So can anyone help me with this?
    Thanks in advance!

    Check Gestures in System Preferences > Trackpad
    It's working here on Safari 7  /  v10.9 Mavericks

  • Can i use flash for ui and interact with c++ builder for the rest

    i know flash can be used in c# in visual studio but i dont remember a thing of this interaction.
    is it possible to interact with c++ builder and how?
    the scenario is simple
    use flash for UI (showing-viewing data) maybe for a kiosk or something without mouse simply with touch input,
    use c++ builder for the rest , database connection data proccessing etc
    any info will be greatly appreciated
    thanks

    I would advise proper punctuation and grammar on a public forum, but to answer your questions, yes, yes you can! Flash can be used to produce any commercial imagery or animations for the purpose of making profit, as long as you have a valid license you purchased from Adobe. You bought it, you can use it for whatever you want.
    By "book", I assume you mean the "tutorial" book series made by Adobe? If so, the name of the series is "Classroom in a Book", there's one for each versions of Flash. Personally it hasn't been of much use and I would advise simply practicing by yourself and getting familiar with the tools. Look for online tutorials and publicly available projects and see how they work.

  • CRM ABAP development and interaction with SAP R/3

    Hi Experts,
    I am an ABAPer and have close to 3 years of development experience in ABAP, now i was trying to understand how exactly a CRM system is intergrated with SAP R/3 . Below are few of the basic question i have
    1. How does R/3 interact with CRM, searching in the forum i just got to know its through RFC . Can anyone give me specific technical details like how R/3 and CRM interact in a real time scenario .
    2. Ca any one also give me an real time development example that was done in CRM to interact with SAP R/3 and explain me the basic steps involved in it, this might give me clear picture of how developments happen in CRM and also how CRM and SAP interacts with each other .
    Your quick response would be greatly appreciated .
    Regard's
    Sudheer V

    with repect to programming , it is similar to R/3 ABAP devlopment . It all depends on scenarios:
    1) For eaxmple we use BADI's to put some extra validations / additional data when you are creation order
    2) unlike R/3 where we use SAP GUI trnsactions for creating orders, in CRM we have IC web client techonolgy where we can create orders through web.This is based on BSP technology. In order to add additinal fields on the screen for we use easy enhancment workbench tool(EEWB).this is something new in CRM when compared to R/3.

  • Pacman frontend in Java - Howto interact with alpm

    I plan to write a(nother :-) ) GUI frontend to Pacman using Java + Swing.  However I need some advice regarding how should I interact with Pacman.
    Basically my requirements are:
    1.  Reading/Searching package database
    2.  Showing a download progress bar
    3.  Showing a progress bar when Pacman is installing/removing package(s)
    As 'alpm' is a C library it's not easily accessible from Java.  The only and perhaps dummest solution that I can think of is to write my own pseudo-alpm library to handle the requirements but I'd seriously rather avoid the re-work and bugs of such a process.  Is there any other way?
    I'd appreciate any idea/hint.  TIA,
    Bahman

    If you have some success creating jni bindings to libalpm you might consider creating an AUR package to join the lua, perl and python packages that are there now.

  • Can a java code interact with trigger

    Hi guyz ,
    is there any way by which a trigger can interact with JDBC ?
    I want to check the database each time its updated and if some condition is violated , the info((row from table which has voilated some rule) is passed to java code which can then take necessary action . Can anyone help me out in this because i am not aware of any way by which a trigger can interact with java code .
    Regards,
    Nikhi

    nikhil456123 wrote:
    Hi guyz ,
    is there any way by which a trigger can interact with JDBC ?
    I want to check the database each time its updated and if some condition is violated , the info((row from table which has voilated some rule) is passed to java code which can then take necessary action . Can anyone help me out in this because i am not aware of any way by which a trigger can interact with java code .Note that even though it might be possible you might want to consider that it isn't necessarily a good idea.
    Say the action is "send email". Then every time an insert/update/delete occurs then an email is sent. That would obviously slow down those operations a lot. Not to mention that if 1000 inserts occur then someone is going to get 1000 emails.
    There can be alternatives that are much better.

  • How to deal with the mouse events when the thread is running

    Hi everybody,
    I have a problem with my program.
    Now I want to present a picture for some time in the Canvas,then automatically clear the screen, but when the user press the mousebutton or keybutton, I want to stop the thread and clear the screen.
    How can I receive the mouse event when the thread is running?
    Thanks,

    I use my code in a GUI applet.
    I try to use the code tag, it's the first time.
                   Image im=sd.getStimulus(obj);
                   if(pos==null){
                        g.drawImage(im, (w-im.getWidth(null))/2,(h-im.getHeight(null))/2,null);
                   }else{
                        g.drawImage(im, pos.x,pos.y,pos.w,pos.h,null);
                   try{
                        sleep(showtime);
    //                    Thread.sleep(showtime);
                   }catch(InterruptedException e){}
                   if(pos==null){
                        g.clearRect((w-im.getWidth(null))/2,(h-im.getHeight(null))/2,im.getWidth(null),im.getHeight(null));
                   }else{
                        g.clearRect(pos.x,pos.y, pos.w, pos.h);
                   }

  • Video grabbing and interaction with windows

    hi, few questions...
    is there any way to work with the usb camera or any video device, even if it does not have a api/sdk ... something like Windows Image Acquisition ??
    can i write code that interacte with windows events ?? i mean a program that in case of click on the desktop will do something ??
    it would really really help
    Jaimon

    I'd think that Java is not exactly the language you need... I'm sure you can do much more in VC++. Java's point is having as little to do with the OS as possible; you won't get around using native code.

Maybe you are looking for

  • How can I update my iPod on a new laptop?

    So, iOS 5 is finally out next week. I would like to upgrade to it, however since my old laptop is broke I use my mums laptop for iTunes. How can I update my system without apps beinf rid of? Last time I did it, my apps remaines intact, but I don't kn

  • Bug in Elements 12 with Thumbnails.

    Under PSE-10 I had an occassional bug with thumbnails in that sometimes they disappeared and were replaced with grey squares. Right-clicking "Update Thumbnail" got them back, even if sometimes not for long. I had hoped that in PSE-12 the bug would ha

  • IPhone glitch? IMAP email doesn't appear in inbox...

    I'm trying to setup up an iPhone to receive email on mobile me, however I need it to send from another email address (a work email). I set the outgoing server to my work's server - no problem. However, when viewing the inbox for this account on the i

  • APEX 4.2.1 websheets unable to install

    I read the manual, searched the Forum and Googled, but I can't get websheets demo app to install. No matter what I try, I get "The database objects required to create Websheet applications are either invalid or do not exist." I tried: Create Applicat

  • What is exactly use of module pool

    hi guru. please tell me in real time exactly what is the use of module pool programs. thanks. subhasis.