I used to use the following code to check the idle time on VB6:
VB Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Type POINTAPI x As Long y As Long End Type Private Sub Timer1_Timer() Static lNotActive As Long Static LastCursorPos As POINTAPI lNotActive = lNotActive + 1 GetCursorPos CursorPos If (CursorPos.x <> LastCursorPos.x) Or (CursorPos.y <> LastCursorPos.y) Then LastCursorPos = CursorPos lNotActive = 0 Else For lCounter = 0 To 255 If GetAsyncKeyState(lCounter) > 0 Then lNotActive = 0 Next End If If lNotActive = 180 Then MsgBox "Idle time reached!" End Sub
What about using VB. NET?
Thank you.




Reply With Quote