Itzik984
Itzik984

Reputation: 16804

mouse event, not on Jframe

i want to make my program to work after a mouse button was clicked, but not necessarily on a Jframe of some sort. for example, i want my program to start working after the PLAY button was clicked on windows media player.

is there a way of doing that?

Upvotes: 1

Views: 450

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285415

Yes, but not in standard Java. You want to listen for an event in the OS not in your Java GUI which Java can't do by itself. This can work, but in order for Java to interact closely with the operating system you will need to use the Java Native Interface (JNI) and C/C++ code or Java Native Access (JNA) (which is a bit easier to use in my opinion). I've also done similar stuff in Windows using a Windows scripting language such as AutoIt, and then connect this to the Java application either via sockets or via standard input and output.

Java Native Interface
Java Native Access
AutoIt Windows Scripting Language

Upvotes: 2

Related Questions