Witam. Mam problem z wykrywaniem aktywności użytkownika w programie Visual Studio 2010 w języku vb.net, a mianowicie z keyhook i mousehook.
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
KeyboardHook1.Hook()
MouseHook1.Hook()
LastActivity = System.DateTime.Now
End Sub
Private LastActivity As System.DateTime
Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs)
KeyboardHook1.Unhook()
MouseHook1.UnHook()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = "Nieaktywny od " & DateTime.Now.Subtract(LastActivity).Seconds.ToString() & " sekund"
End Sub
Private Sub KeyboardHook1_KeyBlocked(ByVal e As KeyHook.KeyHookEventArgs) Handles KeyboardHook1.KeyDown, KeyboardHook1.KeyUp
LastActivity = System.DateTime.Now
End Sub
Private Sub MouseHook1_MouseDown(ByVal e As System.Windows.Forms.MouseEventArgs) Handles MouseHook1.MouseDown, MouseHook1.MouseUp, MouseHook1.MouseMove, MouseHook1.MouseWheel
LastActivity = System.DateTime.Now
End Sub
Private Sub Form2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
End Class
Powyżej znajduje się mój kod. Jako załącznik wstawiam zrzut ekranu błędu, który blokuje program. Pozdrawiam