Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting user Idle time in C#?

I found this tutorial on how getting Idle time of the user Idle Time.

The problem is that it will only work if the application runs on the user.

And my application runs on SYSTEM.

How can I get the idle time? or if PC is idle?

like image 687
Danpe Avatar asked Jun 27 '11 14:06

Danpe


1 Answers

I know this answer has already been accepted but I just wanted to add this in case people wanted to do the same thing in a Terminal Services enviroment.

Cassia is a open source library that puts .NET wrappers around the Windows Terminal Services API. I have used it for my server management and it works really well. You can get the idle time for any session by calling ITerminalServicesSession.LastInputTime

like image 76
Scott Chamberlain Avatar answered Nov 04 '22 17:11

Scott Chamberlain