OS-level window event tracking in Java

I have a requirement to track how much the user interacts with various applications running on their machine. It seemed logical to me to keep a window focus event log with timestamps that tell you which applications were in focus during the day.

We have something else to do in this application, which would be right in Java. However, I did not program the GUI in Java, so I’m not sure that you can get information about OS level windows through the awt API. Is it possible? Would there be another way to do this through JNI or would you need a native application for this?

PS: I know that this requirement sounds a little vile, but I'm only here to determine how technically possible it is. Please do not shoot the messenger, that was not my idea. :)

+1
source share
8 answers

Focal events can work; You can also consider Windows keyboard and mouse hooks . Using either of these approaches, you will want to create a DLL (native code) and use the JNI to access it.

+5
source

Without resorting to my own code, I do not think it will be possible.

+5
source

You can look for a library for testing windows - some of them are designed to create and intercept native win32 events.

+1
source

I do not think this is possible using AWT. Java does not have access to processes for other applications.

0
source

I think you should use a different language. There are other languages, such as C ++, for example, which are predefined for such problems :)

0
source

Basically you ask that your application will be included in OS notifications about other applications. You may need either an application that runs other applications as child processes, or uses something like a rootkit API to set permissions that exceed the standard application.

If the goal is to find out how long the user is interacting with your application, you can get some approximate ideas by looking at the processor time planned for your application, or some relation to the delays between I / O events and displaying statistics about how active the user is.

Otherwise, I think you can contact some spyware developers to get what you need.

0
source

If you want to do this with Java and don’t want to write your own custom code, you can try SWT . I doubt it has platform agnostic ways to accomplish what you want, but you can navigate the Windows classes, especially org.eclipse.swt.internal.win32.OS.

0
source

we can also keep track of the Windows task list in order to trace the application used by the user and its easy to read console in java, and you can also get process data from it, but you need a little processing of heavy lines, bcz all the data you get, will be in a string format, and you will need to get the necessary data from you to make it useful, if you need additional help, I can provide a code for this to track and save this data for tracking, but this solution will not be predelyat event window, his team will provide information about the task,

0
source

Source: https://habr.com/ru/post/1436932/


All Articles