by Frédéric Thibault (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating:
(2 Votes)
this code show how to make an Auto Away like ICQ with Windows Api call GetLastInputInfo. Only work on Nt, 2000, and Xp not on 98,me...
Assumes
The value return to dwtime is the last time when the user move the mouse or use the keyboard. The time begin when the session is open.
Put a Timer and a textbox on a form. Name the textbox text1 and timer timer1 and copy and past this code.
Private Type tagLASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Private Declare Function GetLastInputInfo Lib "user32" (ByRef LASTINPUTINFO As tagLASTINPUTINFO) As Long
Private Sub Timer1_Timer()
Dim mLast As tagLASTINPUTINFO
mLast.cbSize = Len(mLast)
Call GetLastInputInfo(mLast)
Me.Text1.Text = mLast.dwTime
End Sub