Imports System.Runtime.InteropServices
Public Class cUserActivity
    Declare Function GetLastInputInfo Lib "user32" (ByRef plii As LASTINPUTINFO) As Boolean
    'Private WithEvents T As New Timer With {.Interval = 1000, .Enabled = True}

    Structure LASTINPUTINFO
        Public cbSize As Integer
        Public dwTime As Integer
    End Structure

    Shared Function GetLastInputTime_Seconds() As Integer
        Static LastInput As New LASTINPUTINFO()
        LastInput.cbSize = Marshal.SizeOf(LastInput)
        LastInput.dwTime = 0
        GetLastInputInfo(LastInput)
        Return (Environment.TickCount - LastInput.dwTime) / 1000
    End Function
    Shared Function GetLastInputTime_Minutes() As Integer
        Return GetLastInputTime_Seconds() / 60
    End Function

    'Private Sub T_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles T.Tick
    '    Me.Text = "Letzte Aktivität vor " & GetLastInputTime() & " Sek."
    'End Sub
End Class
