I wrote a time-tracker app that does something similar back in the day, to track how I was spending time on various projects/applications, etc. The idea was to track my application usage locally, and use a POST request to a web server for centralized logging. I could also run this app on any machine I wanted, and the POST request would still go back to a central server, so I could track my own activity across multiple machines.
One thing you could use is JNI to bind to the Win32 API, which can then give you access to Window titles, process information, etc.
This Q/A should get you started:
How can I read the window title with JNI or JNA?
Somewhere (I can't find it right now) there's a .JAR
on the net that wraps the win32 API, making this sort of functionality very simple to do in Java.