• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Detecting Key Presses in Windows (without focus)

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 )
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic