tags:

views:

33

answers:

2

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.

+3  A: 

Lock your computer, [Windows Key]+L, when you get up.

Tom Anderson
Yes, I try to do that, but sometimes I forget it.
Kiewic
Stop forgetting, its a general joke at our office, whoever leaves their computer unlocked, someone sends an email to the team saying they will bring in donuts the next day, then they have to bring in donuts.
Tom Anderson
@TomAnderson The same joke here, and what is worse, I have an IBM ThinkPad T43, it doesn't have Windows logo keys.
Kiewic
CTRL+ALT+DELETE -> Lock Computer
Tom Anderson
Change your screen saver to have a short timeout and require a password when you come back.
Adrian McCarthy
A: 

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);
Brian R. Bondy