I\'m writing code that need to run only when there is no human activity on the PC, like when the screensaver is running. Any suggestions on how to do this in c++ under windows?<
Maybe there is confusion for some people here with plii.dwTime
plii.dwTime gives the timestamp date of last input, it doesn't give time beteween now and the last input
for this you have to sub it to GetTickCount() :
LASTINPUTINFO plii;
plii.cbSize = sizeof(LASTINPUTINFO);
plii.dwTime = 0;
if (GetLastInputInfo(&plii) != 0)
{
cout << "Last activity : " << GetTickCount() - plii.dwTime << " (ms)" << endl;
}
else {
cout << "GetLastInputInfo ERROR" << endl;
}