0

In my WPF app, I have to detect the System Idle Time (that includes not using mouse, keyboard, joystick).

I used GetLastInputInfo to get the idle time of the system, but I found that it's working only for input from mouse or keyboard, but not from joystick.

Is there a way or any Win32 API that can give the LastInputInfo by detecting the input from all three devices (mouse, keyboard, joystick)?

Adi Lester
  • 24,731
  • 12
  • 95
  • 110
  • GetLastInputInfo is already a good start, but for the joystick i'm pretty sure that its not covered in the winapi. Or even when it is, it might not accomondate joysticks acquired through directinput, xinput and similar libraries. A keyboard and a mouse are tightly integrated in the win api, a joystick is not. – dowhilefor Jul 28 '12 at 19:19

1 Answers1

0

You can register to receive RAW Input messages. The example below asks for Raw Input from a joystick, but you could also ask for Raw Input from Mice and Keyboards if you wanted...or you can just stick to using GetLastInputInfo for those cases.

Use RIDEV_INPUTSINK on dwFlags if you want to receive the events even when your application is not in the foreground.

There should be enough in the links below to do what you want...take bits and pieces from each reference.

Then you need to define a callback to receive Windows messages, and then look for any WM_INPUT .

I don't think you have to use a system hook, but there's a link that mentions that here:

Community
  • 1
  • 1
Colin Smith
  • 12,375
  • 4
  • 39
  • 47