tags:

views:

66

answers:

3

In order to detect user absence GetLastInputInfo() can be used.

I want to make GetLastInputInfo() return that I've just used keyboard/mouse all the time - as I've been actively using the computer so that whoever relies on GetLastInputInfo() thinks I'm actively using the computer.

Can I use any Windows API functions to achieve that?

+3  A: 

You're looking for the SendInput function.

SLaks
Can that be used without interfering with any concurrent real activity?
Martin Smith
You could set a mouse or keyboard hook to check whether there is any real activity. Alternatively, you could press the `F15` key.
SLaks
Ah, Good thinking!
Martin Smith
+3  A: 

Have you tried to simply move the mouse up and down a bit (15 pixels or so) with SendInput()?. I can't remember if NT6+ only resets the timeout for real hardware input or not.

The other options are:

Anders
+1  A: 

What is this for? Do you just want to disable the screensaver? If that's the case, then you're probably better off looking at the SetThreadExecutionState function.

Dean Harding