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.
source share