0

ユーザーの非アクティブをログに記録しようとしていますが、システムのアイドル時間を取得するメソッドを呼び出そうとすると、次のエラーがスローされます

"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;
}

ありとあらゆる助けをいただければ幸いです=]

4

3 に答える 3