VB Code:
'Create a new project with a timer control
Option Explicit
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Private Declare Function GetLastInputInfo Lib "user32" (plii As Any) As Long
Dim test As Long
Private Sub Timer1_Timer()
Dim lii As LASTINPUTINFO
lii.cbSize = Len(lii)
Call GetLastInputInfo(lii)
If test = lii.dwTime Then
Debug.Print "Idle " & Format$(Now, "dd-mmm-yyyy HH:mm:ss")
Else
Debug.Print "Not Idle " & Format$(Now, "dd-mmm-yyyy HH:mm:ss")
End If
test = lii.dwTime
End Sub