I’m trying to achieve mouse movements with SendInput.
There is code that got from Pinvoke, http://www.pinvoke.net/default.aspx/user32.SendInput
But it doesn’t work for me I’m getting those errors:Code:<DllImport("user32.dll", SetLastError = True)> _ Private Shared Function SendInput(ByVal nInputs As Integer, ByRef pInputs As InputLanguage, ByVal cbSize As Integer) As Integer End Function Public Class Form1 Private Declare Function SendInput Lib "user32.dll" (ByVal cInputs As Integer, ByRef pInputs As INPUT, ByVal cbSize As Integer) As Integer Private Structure INPUT Dim dwType As Integer Dim mkhi As MOUSEKEYBDHARDWAREINPUT End Structure Private Structure KEYBDINPUT Public wVk As Short Public wScan As Short Public dwFlags As Integer Public time As Integer Public dwExtraInfo As IntPtr End Structure Private Structure HARDWAREINPUT Public uMsg As Integer Public wParamL As Short Public wParamH As Short End Structure <StructLayout(LayoutKind.Explicit)> _ Private Structure MOUSEKEYBDHARDWAREINPUT <FieldOffset(0)> Public mi As MOUSEINPUT <FieldOffset(0)> Public ki As KEYBDINPUT <FieldOffset(0)> Public hi As HARDWAREINPUT End Structure Private Structure MOUSEINPUT Public dx As Integer Public dy As Integer Public mouseData As Integer Public dwFlags As Integer Public time As Integer Public dwExtraInfo As IntPtr End Structure Const INPUT_MOUSE As UInt32 = 0 Const INPUT_KEYBOARD As Integer = 1 Const INPUT_HARDWARE As Integer = 2 Const KEYEVENTF_EXTENDEDKEY As UInt32 = &H1 Const KEYEVENTF_KEYUP As UInt32 = &H2 Const KEYEVENTF_UNICODE As UInt32 = &H4 Const KEYEVENTF_SCANCODE As UInt32 = &H8 Const XBUTTON1 As UInt32 = &H1 Const XBUTTON2 As UInt32 = &H2 Const MOUSEEVENTF_MOVE As UInt32 = &H1 Const MOUSEEVENTF_LEFTDOWN As UInt32 = &H2 Const MOUSEEVENTF_LEFTUP As UInt32 = &H4 Const MOUSEEVENTF_RIGHTDOWN As UInt32 = &H8 Const MOUSEEVENTF_RIGHTUP As UInt32 = &H10 Const MOUSEEVENTF_MIDDLEDOWN As UInt32 = &H20 Const MOUSEEVENTF_MIDDLEUP As UInt32 = &H40 Const MOUSEEVENTF_XDOWN As UInt32 = &H80 Const MOUSEEVENTF_XUP As UInt32 = &H100 Const MOUSEEVENTF_WHEEL As UInt32 = &H800 Const MOUSEEVENTF_VIRTUALDESK As UInt32 = &H4000 Const MOUSEEVENTF_ABSOLUTE As UInt32 = &H8000 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
Error 1 Identifier expected. C:\Documents and 2 91 WindowsApplication1
Error 2 Type 'StructLayout' is not defined. C:\Documents and 26 6 WindowsApplication1
Error 3 Type 'FieldOffset' is not defined. C:\Documents and 28 10 WindowsApplication1
Error 4 Type 'FieldOffset' is not defined. C:\Documents and 29 10 WindowsApplication1
Error 5 Type 'FieldOffset' is not defined. C:\Documents and 30 10 WindowsApplication1
Please help!





Reply With Quote