In general, the Screensaver will run when we do nothing for a period of time.
Now i wanna know how to get the unactive time.
In another word,i want to make a program which would run a function if we do nothing for a period of time.
Now i can use mouse or keyboard hook to solve the problem.
But you know,it needs administrator permissions. In another word,if in win vista or win 7,it is nauseating because of the UAC.
I need an API such to get last windows active time.
views:
256answers:
2
+1
A:
Look into CallNtPowerInformation() and request a SYSTEM_POWER_INFORMATION structure.
John Deters
2009-09-18 02:01:56
The SYSTEM_POWER_INFORMATION structure "Contains information about the idleness of the system." TimeRemaining is "The time remaining in the idle timer, in seconds." Idleness is that number expressed as a percentage.typedef struct _SYSTEM_POWER_INFORMATION { ULONG MaxIdlenessAllowed; ULONG Idleness; ULONG TimeRemaining; UCHAR CoolingMode;}SYSTEM_POWER_INFORMATION, *PSYSTEM_POWER_INFORMATION;
John Deters
2009-09-18 03:15:28
+2
A:
The CallNtPowerInformation()
API is to get the last power information
I should use GetLastInputInfo()
Edwin Tai
2009-09-18 02:51:52
GetLastInputInfo() does not give you system-wide idle time for when Windows will go idle or when the screensaver will kick in. It only gives you the idle time for the running process. CallNtPowerInformation() gives you the system idle time.
John Deters
2009-09-18 05:06:25