我试图记录用户活动,但是当我尝试调用它得到它抛出一个错误说为什么我不能使用实例引用访问此方法?
"Member 'NotifyIcon.Inactivity.GetIdleTime()' cannot be accessed with an instance reference; qualify it with a type name instead"
这是我获取用户的空闲时间自定义事件系统空闲时间的方法
private void Inactivity_Inactive(object sender, EventArgs e)
{
inactivity.GetIdleTime();
}
并用代码的方法以获得空闲时间
public static uint GetIdleTime()
{
LASTINPUTINFO lastInput = new LASTINPUTINFO();
lastInput.cbSize = (uint)Marshal.SizeOf(lastInput);
GetLastInputInfo(ref lastInput);
return (uint)Environment.TickCount - lastInput.dwTime;
}
任何和所有帮助将不胜感激=]
感谢详细的解答,您的解决方案工作= d –