Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27333

VS 2010 Clicking mouse with keyboard

$
0
0
Hello, need a bit help here,

I have been making a program that can control the mouse via the number pad, similar to Ease of access center from windows.

I have got the maneuver features working, but I am stuck at the click commends.

I want to click the mouse by pressing NumPad5. After doing some googling, here's my attempt:

Code:

    Public Declare Sub mouse_event Lib "user32." Alias "mouse_event" (ByVal dwFlags As Long)

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Me.Cursor = New Cursor(Cursor.Current.Handle)
        If e.KeyValue = Keys.NumPad5 Then
            mouse_event(&H2)
        End If
    End Sub

    Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        Me.Cursor = New Cursor(Cursor.Current.Handle)
        If e.KeyValue = Keys.NumPad5 Then
            mouse_event(&H4)
        End If
    End Sub

But it return the following error, what did I do wrong?
Quote:

A call to PInvoke function 'Mouseboard!Mouseboard.Form1::mouse_event' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Viewing all articles
Browse latest Browse all 27333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>