Sto cercando un modo per rilevare se l'utente è rimasto inattivo per 5 minuti quindi fare qualcosa, e se e quando tornerà quella cosa si fermerà, ad esempio un timer.VB Detect Tempo di inattività
questo è quello che ho provato (ma questo rileverà solo se form1 è stato inattivo/non cliccato o niente):
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
Il tuo obiettivo è rilevare attività tastiera/mouse al di fuori dell'applicazione? –
Sì, sì e se non viene rilevata alcuna attività, eseguire un comando // codice –