Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, pInputs As INPUT_TYPE, ByVal cbSize As Long) As Long
Private Const MOUSEEVENTF_MOVE = &H1
Private Const INPUT_MOUSE = 0
Private Type MOUSEINPUT
dx As Long
dy As Long
mouseData As Long
dwFlags As Long
dwtime As Long
dwExtraInfo As Long
End Type
Private Type INPUT_TYPE
dwType As Long
xi(0 To 23) As Byte
End Type
Private inputEvent(0) As INPUT_TYPE
Private Sub Form_Load()
Dim mouseEvent As MOUSEINPUT
' Load up the event record
mouseEvent.dx = 0
mouseEvent.dy = 0
mouseEvent.mouseData = 0
mouseEvent.dwFlags = MOUSEEVENTF_MOVE
mouseEvent.dwtime = 0
mouseEvent.dwExtraInfo = 0
' Copy the record into the input array
inputEvent(0).dwType = INPUT_MOUSE
CopyMemory inputEvent(0).xi(0), mouseEvent, Len(mouseEvent)
End Sub
Private Sub Timer1_Timer()
Dim intX As Integer
intX = SendInput(1, inputEvent(0), Len(inputEvent(0)))
End Sub