Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Runtime.InteropServices
- Public Class Form1
- <DllImport("user32.dll")> Private Shared Function GetLastInputInfo(ByRef plii As LASTINPUTINFO) As Boolean
- End Function
- <StructLayout(LayoutKind.Sequential)>
- Structure LASTINPUTINFO
- Public cbSize As UInteger
- Public dwTime As Integer
- End Structure
- Dim lastInput = New LASTINPUTINFO()
- Dim alreadyWarned As Boolean = False
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- lastInput.cbSize = Marshal.SizeOf(lastInput)
- lastInput.dwTime = 0
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- GetLastInputInfo(lastInput)
- If ((Environment.TickCount - lastInput.dwTime) / 60000) >= 30 Then '>= 30 minutes
- If Not alreadyWarned Then
- alreadyWarned = True 'Do this so we don't spam a message box every second
- MsgBox("You've been idle for a while")
- End If
- Else
- alreadyWarned = False 'Reset if the system is no longer idle
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement