Option Strict On
Option Explicit On
Imports System.Runtime.InteropServices
Public Class Form1
Private Declare Function GetLastInputInfo Lib "user32.dll" _
(ByRef plii As PLASTINPUTINFO) As Boolean
Private Structure PLASTINPUTINFO
Dim cbSize As Integer
Dim dwTime As Integer
End Structure
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Integer, _
ByVal uParam As Integer, ByRef lpvParam As Integer, _
ByVal fuWinIni As Integer) As Integer
Private Const SPI_GETSCREENSAVETIMEOUT As Integer = 14
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim oPLII As PLASTINPUTINFO
oPLII.cbSize = Marshal.SizeOf(oPLII)
GetLastInputInfo(oPLII)
TextBox1.Text = CType((Environment.TickCount - oPLII.dwTime) / 1000, String)
If (Environment.TickCount - oPLII.dwTime) / 1000 >= 10 Then
'MsgBox("system inactive")
End If
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
End Sub
End Class