Question

I'm trying to make a kind of a keylogger in Java. I got an app that allowed people to get their RSS feeds on their desktop and I want to make a quick access. By the way, I need something that can do that:

  • I start my java jar file and it minimized in the system tray.
  • The user does what he wants to do (Surfing, Watching movies, etc...).
  • He pressed a key combination (CTRL + I) and then the java window opens and displays a GUI where he can check for news and modify app configuration.
  • Now he can minimize the window (System tray icon) and keep using his computer normaly.

My app has to be totally cross platform. All things are done except this feature. I've tried to do it with KeyStroke and even System.in but they only catch key combination when the user has the window as active.

So, is there a way to catch key combination from outside the app (Like a transparent overlay) without using JNI or JNA (That's what my searches gave me).

Thanks for your help.

Was it helpful?

Solution

No, you'll have to drop to some system dependent library, i.e. use some form of JNI.

The different built-in levels of granularity are:

WHEN_ANCESTOR_OF_FOCUSED_COMPONENT

Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is an ancestor of the focused component or is itself the focused component.

WHEN_FOCUSED

Constant used for registerKeyboardAction that means that the command should be invoked when the component has the focus.

WHEN_IN_FOCUSED_WINDOW

Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component

OTHER TIPS

This cannot be done. No operating system worth its salt in today's world will let you just log all keystrokes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top