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?
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
精彩评论