Hi, I would like to catch as an event each time that the focused application on Windows change, preferently in C#. I need to prevent that my co-workers can send emails from my Outlook account when I stand up.
Thanks for your help.
Hi, I would like to catch as an event each time that the focused application on Windows change, preferently in C#. I need to prevent that my co-workers can send emails from my Outlook account when I stand up.
Thanks for your help.
You would be better off tracking idle time of keyboard and mouse via using Windows Hooks. Here is a project (CodeProject: Processing Global Mouse and Keyboard Hooks in C#) to get you started. You can modify it slightly and get a working version.
You can do something like this once the keyboard and mouse haven't been used for X minutes:
ProcessStartInfo psi = new ProcessStartInfo("rundll32.exe");
psi.Arguments = "user32.dll, LockWorkStation";
Process.Start(psi);