• Post Reply Bookmark Topic Watch Topic
  • New Topic

Listen to mouse events outside a java window  RSS feed

 
Sandy GS
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to listen to mouse events anywhere on the screen (desktop).
Is there a way I could listen to mouse events outside of a java window (on the desktop for e.g.) anywhere on the screen after the window has been deactivated (minimized)? ... other than writing a native method call.
I tried this but does not seem to give me what I want... Is this possible in java, in the first place?
<pre>
java.awt.Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
public void eventDispatched(AWTEvent aWTEvent) {
System.out.println("EVENT IS:" + aWTEvent);
}
}, AWTEvent.MOUSE_EVENT_MASK);
</pre>
I see that the output prints only entered/exited/clicked/pressed/released on the window but nothing happens for what I do outside the window.
Thanks.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, this isn't possible using AWT... you'd have to use native code...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!