• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

capturing all keystroke??

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is there a way to capture all keystrokes, in an java app, even though the app is not under keyboard focus???

actually i want to write an java application which runs in background and should pop on screen when i press a key combo such as alt-shift-p so something like that, can it be done with java.

also i m planning to write a java app, that would launch my fav apps at press of a keystroke, even if that app dosenot have keyboard focus.

i m not in position to write native code in c/c++,
and it would be ok if the solution is windows specific.

please help
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jigar,

Your project sounds too close to the OS for Java developpement. Howewer, you may consider using Windows' system tray to activate your background application with a click. To achieve that, I suggest you to check theses packages :

- http://jeans.studentenweb.org/java/trayicon/trayicon.html
- http://systray.sourceforge.net/
- http://www.javaapis.com/jtray/

Best regards,
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, unfortunately Lionel is right on this one. It's not possible to trap the keystrokes unless a container of some sort has focus. I know that you said you can't do native C/C++, but that would be a solution to your problem... i.e. writing some native code to trap the keystrokes and calling this native code through JNI.

David
 
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic