如何使用C#语言在Windows上运行的特定应用程序上获取空闲时间和用户活动时间。 [英] How to get the idle time and user active time on particular application running on windows using C# language.

查看:107
本文介绍了如何使用C#语言在Windows上运行的特定应用程序上获取空闲时间和用户活动时间。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现窗体表单应用程序,它将跟踪用户的工作情况,比如他花在特定应用程序上的时间。任何人都可以告诉我如何获取进程空闲时间以及如何找到用户与应用程序交互的总时间。实际上,当处理终止或退出时,我怎样才能获得确切的时间。谢谢 提前... 





我尝试了什么:



流程[]流程= Process.GetAllProcesses();

foreach(流程中的var项目)

{

Console.Writeline(item.startTime);

Console.writeline(item.MainWindowTitle);

控制台。 Writel(item.exitTime);

}

解决方案

试试这个:ProcessInfo Class(System.Web) [ ^ ]开头。



另外,如果您查看Taskmanager进程信息选项卡,您可以看到各种可用的列,您可以进行一些算术运算。



但等等!你真的不太了解你在寻找什么。 CPU使用率和用户时间不一定相关。用户需要多长时间才能完成工作以获得50毫秒的CPU时间?祝你好运。应用程序可以启动而且几乎没有触及 - 但是时钟一直在运行。



如果你想知道某人的工作有多难 - 那么看看他们做了什么 - 这只是第一个近似值。例如,编码对于经理的眼睛来说非常高效,即使它很容易 - 而且看起来不那么高效,因为必须解决大量的问题。




结果

I want to implement window form application which will track the user works like how much time he spend on particular application. Can anybody tell me how can i get the process idle time and how to find the total time user interaction with application. actually how can i get the exact time when process the terminated or exited. Thanks in Advance ...



What I have tried:

Process[] process=Process.GetAllProcesses();
foreach(var item in process)
{
Console.Writeline(item.startTime);
Console.writeline(item.MainWindowTitle);
Console.Writeline(item.exitTime);
}

解决方案

Try This: ProcessInfo Class (System.Web)[^] to begin with.

Also, if you take a look at the Taskmanager process info tab you can see the various columns available and you can do some arithmetic.

But wait! You will not really know much about what you're looking for. CPU usage and user time are not necessarily related. How long does a user spend doing work in order to require 50ms of CPU time? Good luck with that idea. Applications can be started and hardly touched - but the clock keeps running.

If you want to know how hard someone works - then see what they get done - which is only a first approximation. Coding, for example, can be very productive to a manager's eyes even if it were easy - and not look productive because massive problems had to be solved.




这篇关于如何使用C#语言在Windows上运行的特定应用程序上获取空闲时间和用户活动时间。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆