Question

I have a requirement to be able to track how much a user interacts with the different applications running on their machine. What seemed logical to me was to keep a log of window focus events with timestamps which would tell you what applications were in focus over the course of the day.

We have some other things to do in this application that would be straightforward in Java. However I haven't done any GUI programming in Java so I'm not sure if it's possible to get information about OS-level windows through the awt API. Is that even possible? Would there be another way to do this through JNI or would a native application be required to do this?

PS: I know that this requirement sounds a little nefarious but I am only here to determine whether or not this is technically possible. Please don't shoot the messenger, this wasn't my idea. :)

Was it helpful?

Solution

Focus events might work; you might also want to consider Windows keyboard and mouse hooks. With any of these approaches, you'll want to create a DLL (native code) and use JNI to access it.

OTHER TIPS

With out resorting to native code I don't think this will be possible.

You might look for a window testing library--some of those are made to create and intercept win32 native events.

I don't think this is possible using AWT. Java has no way of accessing the processes for the other applications.

I think you should consider using another language.
There are other languages like C++ for example that are predistinated for this kind of problems :)

You're basically asking that your app be included on OS notifications to other applications. You'll probably need to either have an app that launches the other apps as child processes or use something like a rootkit API to establish permissions above what a normal application is granted.

If the goal is to see how much time a user is interacting with your application, you might get some rough ideas by looking at the CPU time being scheduled to your application or some how looking at delays between I/O events and mapping those into stats about how active the user is.

Otherwise, I think you might be able to contact with some spyware developers to get what you need.

If you want to do this from Java and don't want to write your own native code, you can try SWT. I doubt it has platform-agnostic ways of accomplishing what you want, but you can poke around in the Windows-specific classes, especially org.eclipse.swt.internal.win32.OS.

we can also monitor windows tasklist to trace the application used by a user, and its simple in java to read console and you can also get the process data from it but you will need little heavy string processing in it, bcz all the data which you get will be in the string format and you have to get your required data from it, to make it usefull, if you need further help i can give the code for that to monitor and save that data for tracing, but this solution will not override the window event, its will give the the task information,

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