I want to exit my application if there has been no activity on the PC for 10 mins. How can i use the timer control to do this ?
Printable View
I want to exit my application if there has been no activity on the PC for 10 mins. How can i use the timer control to do this ?
I don't know a simple answer to your question but I wanted to point out that Timers are not controls. If it doesn't inherit the Control class then it's not a control.
you can use an API call in your timer_tick event
vb Code:
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 Sub Timer1_Tick(ByVal sender As System.Object, ByVal 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) End Sub End Class
It says Marshal is not declared. What should i do ?
Also where do i set the ending time ?
I figured it out... Thanks Paul !