Detecting that the user is away from the PC with .NET

前端 未结 4 958
借酒劲吻你
借酒劲吻你 2020-12-20 04:10

I have a desktop application in which I would like to know two things:

  1. Is the user currently on the PC (more specifically, is he giving any input to the PC), s
4条回答
  •  情深已故
    2020-12-20 04:40

    You could use a global keyboard/mouse hook and just reset your "counter" to 0 when you receive an event from either. When your counter reaches the idle time that you're looking for, perform your background actions.

    There is some code here that allows you to easily do the hooking in .NET: http://www.codeproject.com/KB/cs/globalhook.aspx

提交回复
热议问题