I would like to know the current idle time from user input on a given Windows XP machine programmatically. I am using VBA in MS Access. What options do I have?
+2
A:
I used the following to obtain the solution.
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function GetLastInputInfo Lib "user32" (plii As Any) As Long
Private Type LastInputInformation
cbSize As Long
dwTime As Long
End Type
Public Function GetUsersIdleTime() As Long
Dim lii As LastInputInformation
lii.cbSize = Len(lii)
Call GetLastInputInfo(lii)
GetUsersIdleTime = FormatNumber((GetTickCount() - lii.dwTime) / 1000, 2)
End Function
There are other parts of the system which can be idle such as,
- CPU
- Disk
- Network
- Other devices
To find out more regarding performance and other idle types see this SO post here.
Curtis Inderwiesche
2010-04-07 00:47:22
This is somewhat beyond the scope of the question, but can a benevolent poster please explain what the 'idle time' is? It sounds useful.
PowerUser
2010-04-07 13:27:04
Thanks for the link.
PowerUser
2010-04-07 14:58:52