CodeItBetter Programming Another VB Programming Blog

How to find whether system is idle or not

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'System & API - How to find whether system is idle or not
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
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.