How to determine the idle state of a system, etc. In vb6

I'm trying to create my own messenger and want the user to go into standby / idle mode if the computer has not been used for so long. Does anyone have a great idea on how to do this?

+3
source share
1 answer

This is how I implemented this functionality several years ago. The fnIdleTime function will tell you how many seconds have passed since the user touched the mouse or keyboard.

Public Declare Function timeGetTime Lib "WINMM.DLL" () As Long

Private Type LASTINPUTINFO
  cbSize As Long
  dwTime As Long
End Type

Public Declare Function GetLastInputInfo Lib "user32.dll" (plii As LASTINPUTINFO) As Long

Public Function fnIdleTime() As Long

  Dim lii As LASTINPUTINFO

  lii.cbSize = Len(lii)

  If (GetLastInputInfo(lii) > 0) Then
    fnIdleTime = (timeGetTime - lii.dwTime) \ 1000
  End If

End Function
+4
source

All Articles