This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detecting Key Presses in Windows (without focus)

 
Micho Lee
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Layne
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like an awfully dangerous application to write (sounds a lot like spyware). Why do you need to do such a thing?
 
Paulo Pontes
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still not a Java thing. The spyware people call programs like that "Keystroke Loggers", so you could use that term if you're doing internet searches.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic