0

I am currently attempting to write a Windows Service that will shutdown the computer after a predetermined amount of time of system/user inactivity. In order to do this (at both the logon screen and when logged in) I need to monitor any keyboard event or mouse movement.

I am aware of the "LASTINPUTINFO" method. This only works when the user is logged in.

I am also aware of system level hooks. I can get that to work perfectly in an application but not as a Windows Service.

Do I need to write a driver or something to hook into the WH_KEYBOARD_LL or WH_MOUSE_LL at system level?

  • You'd need to either use a device driver (probably a pair of filter drivers) or launch a process in the context of the active session, as per http://stackoverflow.com/q/10770929/886887 – Harry Johnston Apr 22 '16 at 05:49
  • You need an application that runs in an interactive user session to monitor user input. Have the service start that application when a user logs in. If the service hasn't started an interactive application, use a timer to implement the shutdown timeout. – IInspectable Apr 22 '16 at 05:51

0 Answers0