For a status monitor i would need to monitor user activity. I do not need to know what the user is doing, all i need to know is that he is doing something. Moving the mouse, typing something and so on. The program is used to show in the company who is at the desk and who is gone from the workstation for the phone centralinist. so i would need to monitor the user activity, and if there is no activity for 2 minutes the user is away from keyboard.
I was thinking of using the keyboard hook and the mouse position to monitor changes every lets say 5 seconds. On every change I reset a counter.
Is there a better way? for example reading the screensaver countdown or something like that?
1) Go to your form properties and change the Opacity to
0%. Then change the FormBorderStyle to
None, the WindowsState to
Maximized and the TopMost to
2) Create two timers go to their properties and change the Enabled to
3) Set the Interval of Timer1 to
5000 and the Interval of Timer2 to
4) Paste this Code to your Form.
Dim str As String = "" Dim active As Boolean = True Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim MousePosition As Point MousePosition = Cursor.Position If Not str = MousePosition.ToString Then str = MousePosition.ToString active = True Timer2.Stop() Timer2.Start() End If End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick active = False notactive() Timer2.Stop() End Sub Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown active = True Timer2.Stop() Timer2.Start() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim MousePosition As Point MousePosition = Cursor.Position str = MousePosition.ToString End Sub Public Sub notactive() 'Some code End Sub
On the sub
noactive put what you want to do when the user is inactive for 2 minutes.
true when the user is active and
false when the user is inactive for 2 minutes.
This program monitors mouse movement and keyboard activity.