Problems with a mouse API function...
I'm using this function I wrote:
VB Code:
Public Sub MoveMouse(X1 As Long, Y1 As Long, X2 As Long, Y2 As Long)
'Rectangle
Dim mmRECT As RECT
'Y increment
Dim XInc As Double
Dim YInc As Double
XInc = ((X2 - X1) / 10000)
YInc = ((Y2 - Y1) / 10000)
'Set mouse cursor to hand
Screen.MousePointer = vbCustom
Screen.MouseIcon = LoadResPicture("POINT", vbResCursor)
'Move mouse
Dim i As Double
For i = 0 To 10000
mmRECT.Top = Y1 + (YInc * i)
mmRECT.Bottom = Y1 + (YInc * i) + 1
mmRECT.Left = X1 + (XInc * i)
mmRECT.Right = X1 + (XInc * i) + 1
ClipCursor mmRECT
PauseMe 250
Next
'Set cursor to default
Screen.MousePointer = vbDefault
'Release mouse
ClipCursor &H0
End Sub
'Pause system in a loop temporarily
Public Sub PauseMe(lngPauseDuration As Long)
Dim i As Long
Do Until i = lngPauseDuration
i = i + 1
DoEvents
Loop
End Sub
To force the mouse to move (in a straight line) between two points. The PauseMe function just holds up the processor for a tiny period of time so visual effects can actually be seen (they're too fast otherwise).
Anyway, this function works fine if the points are:
X1 = 0
Y1 = 0
X2 = 12000
Y2 = 12000
(topleft->bottom right)
but in reverse, nothing happens for awhile, and then some time later, the mouse moves as I want it to... it's really quite odd.... :confused: