11

Is there a .NET equivalent to the Windows GetLastInputInfo() API?

I know it's possible to P/Invoke the API but I'm looking for a method or technique that's already built into the .NET framework.

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
Jeff Stong
  • 1,506
  • 4
  • 14
  • 26

2 Answers2

10

There isn't a direct translation of that specific API in the .NET BCL. Fortunately, it's a very easy method to P/Invoke.

That being said, there are other ways to attempt to check user idle state. Most still require P/Invoke at some level (at least all of the ones that handle other applications).

Here is a CodeProject article comparing options.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • 2
    @Cocowalla The linked article shows various options, including completely managed means of monitoring input, etc. – Reed Copsey Jan 20 '12 at 20:23
1

If there isn't another call for this Pinvoke.net provides a P/Invoke solution for this call and necessary struct.

Timothy Carter
  • 15,459
  • 7
  • 44
  • 62