Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse_Event API in VB.Net 2005

Status
Not open for further replies.
Jan 23, 2002
63
0
0
US
I have the following code, which is part of a project where I need to move the mouse to a specific location when the user performs an action. When I run it, I get:

PInvokeStackImbalance was detected
A call to PInvoke function 'TestApp1!TestApp1.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.

Here's the code. I'm guessing there's a problem in the API declaration, in the parameters, but I'm not sure what it is. I also tried using Integer values for the declaration and call, but I get the same error as I do with Int32's:

Please help!

Imports System.Runtime.InteropServices
Imports System.Text

Public Class Form1
<DllImport("user32")> Public Shared Sub mouse_event(ByVal dwFlags As Int32, ByVal dx As Int32, ByVal dy As Int32, ByVal dwData As Int32, ByVal dwExtraInfo As ULong)
End Sub

Public Const MOUSEEVENT_ABSOLUTE = &H8000
Public Const MOUSEEVENT_MOVE = &H1
Public Const MOUSEEVENT_LEFTDOWN = &H2
Public Const MOUSEEVENT_LEFTUP = &H4
Public Const MOUSEEVENT_RIGHTDOWN = &H8
Public Const MOUSEEVENT_RIGHTUP = &H10

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim dwFlags As Int32, Dx As Int32, Dy As Int32, dwData As Int32, dwExtraInfo As ULong
dwFlags = MOUSEEVENT_ABSOLUTE
Dx = 32000
Dy = 32000
dwData = 0
dwExtraInfo = 0

mouse_event(dwFlags, Dx, Dy, dwData, dwExtraInfo)

End Sub
End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top