VB.net app loses mouse & keyboard hook after only a second

Apr 30, 2012 at 5:19 AM

Hello,

   I noticed one of the other members reported a similar problem. However, I am using the control in vb.net instead of using it programmatically. I figured I would use the control first, just to see how it would work. I have noticed, however, it does not take long for the global hook to seem to "unhook". I have an app with two forms: main.vb and setup.vb. Main the the one using the MouseKeyEventProvider control. I have it's enabled property set to false until I want to use it.

I call MouseKeyEventProvider1 like this after my timer has reached 0:

MouseKeyEventProvider1.enabled=true 

The events I am handling are:

    Private Sub MouseKeyEventProvider1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MouseKeyEventProvider1.KeyDown
        e.Handled = True
    End Sub

    Private Sub MouseKeyEventProvider1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MouseKeyEventProvider1.KeyPress
        e.Handled = True
    End Sub

    Private Sub MouseKeyEventProvider1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MouseKeyEventProvider1.KeyUp
        e.Handled = True
    End Sub


    Private Sub MouseKeyEventProvider1_MouseClickExt(ByVal sender As Object, ByVal e As MouseKeyboardActivityMonitor.MouseEventExtArgs) Handles MouseKeyEventProvider1.MouseClickExt
        e.Handled = True
    End Sub

    Private Sub MouseKeyEventProvider1_MouseDownExt(ByVal sender As Object, ByVal e As MouseKeyboardActivityMonitor.MouseEventExtArgs) Handles MouseKeyEventProvider1.MouseDownExt
        e.Handled = True
    End Sub

    Private Sub MouseKeyEventProvider1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MouseKeyEventProvider1.MouseMove
        e.Location.X.Equals(0)
        e.Location.Y.Equals(0)
    End Sub

    Private Sub MouseKeyEventProvider1_MouseMoveExt(ByVal sender As Object, ByVal e As MouseKeyboardActivityMonitor.MouseEventExtArgs) Handles MouseKeyEventProvider1.MouseMoveExt
        e.Handled = True
    End Sub

As soon as the main form loads, the mouse is unable to be used. However, within a few seconds of moving it, it begins working again, and I can do anything with it. In fact, the keyboard works as well, which defeats the whole purpose of using the dll i the first place.

My app is designed to lock users out of using the computer until the app recognizes them using facial recognition.  the app works great, but the global mouse and keyboard does not. Any ideas?

 

Thanks in advance