Estoy buscando una manera de detectar si el usuario ha estado inactivo durante 5 minutos y luego hacer algo, y si y cuando regrese eso se detendrá, por ejemplo, un temporizador.VB Detecta el tiempo de inactividad
Esto es lo que he intentado (pero esto sólo detectará si formulario1 ha estado inactivo/no hecho clic o cualquier cosa):
Public Class Form1
Private Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'You should have already set the interval in the designer...
Timer1.Start()
End Sub
Private Sub form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
Timer1.Stop()
Timer1.Start()
End Sub
Private Sub form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Timer1.Stop()
Timer1.Start()
End Sub
Private Sub form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
Timer1.Stop()
Timer1.Start()
End Sub
Private Sub Timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MsgBox("Been idle for to long") 'I just have the program exiting, though you could have it do whatever you want.
End Sub
End Class
¿Su objetivo es detectar la actividad del teclado/mouse fuera de su aplicación? –
Sí, un poco y si no se detecta actividad, ejecute un comando // código –