I'm writing a java application that runs in the background in a Windows XP environment. I need a way for the application to detect when certain keys have been pressed on the keyboard even when it is not in focus. Kind of like a key logger would do, I need it to detect any keys that might be pressed. Does anyone know how to implement such a "global" key listener so that a key press can be captured at any/all times within Windows?
Help (esp exaple code) would be much appreciated. Thanks in advance!
If I were writing such a program, I probably use C or C++ instead of Java. This is because it sounds highly dependent on platform-specific code. Perhaps this is possible using AWT listeners, but I think KeyListener requires the application to have focus.
Originally posted by Paulo Pontes: I need the same thing!
my app captures the interation between the user and some other app to mimic it later with some changes (it's a bot/macro tool for mmorps )
Suddenly the reason for the image question becomes apparent. Which one is this for? SWG? CoV? CoH? WoW? AC? AC2? EQ? EQ2? DAoC? AO? NC? UO? L? L2? PS? I remember when there was only three, now look at all those acronyms! I probably don't want to know, I'd just have to come kill you. In the game that is. There's plenty of macro software out there for Windows, I suggest using one of those unless you're bound and determined to write your own.
subject: Detecting Key Presses in Windows (without focus)