Darthatron
Massive Troll
So, I'm sure you all know of Cruel's function MoveMouseCC from CruelClient. This is an edited version using "SilentSetCursorPos" (that I made) which sends a message to a window telling it that the mouse has been moved. Meh, I can't explain it very well... but here it is:
Declares/needed functions.
Silent Functions.
and finally...
Read the comments in Cruel's original code to see what the params do... or just ask.
Download demo in attachment.
Any questions? Post.
Declares/needed functions.
Code:
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Const WM_RBUTTONDBLCLK = &H206
Private Const WM_MBUTTONDOWN = &H207
Private Const WM_MBUTTONUP = &H208
Private Const WM_MBUTTONDBLCLK = &H209
Public Enum MouseEvents
LeftUp = WM_LBUTTONDOWN
LeftDown = WM_LBUTTONUP
RightUp = WM_RBUTTONDOWN
RightDown = WM_RBUTTONUP
MiddleUp = WM_MBUTTONDOWN
MiddleDown = WM_MBUTTONUP
End Enum
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Function Wait(ByVal ms As Long)
ms = timeGetTime() + ms
Do: DoEvents: Loop While ms > timeGetTime()
End Function
Public Function Min(ByVal val1 As Long, ByVal val2 As Long) As Long
Min = val1
If (val2 < val1) Then Min = val2
End Function
Public Function Rand(ByVal Low As Long, ByVal High As Long) As Long
Randomize
Rand = CLng((High - Low + 1) * Rnd) + Low
End Function
Silent Functions.
Code:
Public Function SilentSetCursorPos(ByVal hWnd As Long, ByVal X As Integer, ByVal Y As Integer)
Dim LongXY As Long
'If no window was specified then use the desktop.
If hWnd = 0 Then
hWnd = GetDesktopWindow
End If
'Create a Long to replace the X and Y Integers.
LongXY = (Y * &H10000) Or (X And &HFFFF&)
'Send a message to the selected window to set an invisble cursor to the chosen position.
SendMessage hWnd, WM_MOUSEMOVE, 0&, LongXY
End Function
Public Function SilentMouseEvent(ByVal hWnd As Long, ByVal X As Integer, ByVal Y As Integer, ByVal MouseEvent As MouseEvents)
Dim LongXY As Long
'If no window was specified then use the desktop.
If hWnd = 0 Then
hWnd = GetDesktopWindow
End If
'Create a Long to replace the X and Y Integers.
LongXY = (Y * &H10000) Or (X And &HFFFF&)
'Send a message to the selected window to set an invisble cursor to the chosen position.
SendMessage hWnd, MouseEvent, 0&, LongXY
End Function
and finally...
Code:
Public Function SilentMoveMouseCC(ByVal hWnd As Long, ByVal X As Long, ByVal Y As Long, ByVal Range As Long, ByVal Segments As Long, ByVal PointCount As Long, ByVal Delay As Long, CurrentX As Long, CurrentY As Long)
If PointCount < 3 Then PointCount = 3
Dim u As Double, nc1 As Double, nc2 As Double, nc3 As Double, nc4 As Double
Dim DummyPoint As POINTAPI, p1() As POINTAPI, p2() As POINTAPI
Dim i As Long
ReDim p2(0)
ReDim p1(PointCount + 2)
If Segments < 15 Then Segments = 50
Segments = Segments + Rand(-12, 12)
DummyPoint.X = CurrentX
DummyPoint.Y = CurrentY
X = X + Rand(-Range, Range)
Y = Y + Rand(-Range, Range)
If (Abs(DummyPoint.X - X) + Abs(DummyPoint.Y - Y)) < 150 Then
PointCount = 3
Segments = 15
End If
For i = 0 To PointCount + 2
Select Case i
Case Is < 2: p1(i) = DummyPoint
Case Is >= PointCount: p1(i).X = X: p1(i).Y = Y
Case Else
p1(i).X = Min(DummyPoint.X, X) + Rnd() * Abs(DummyPoint.X - X)
p1(i).Y = Min(DummyPoint.Y, Y) + Rnd() * Abs(DummyPoint.Y - Y)
End Select
Next i
For i = 1 To PointCount
For u = 0 To 1 Step (1 / Segments)
nc1 = -(u ^ 3) / 6 + (u * u) / 2 - u / 2 + 1 / 6
nc2 = (u ^ 3) / 2 - (u * u) + 2 / 3
nc3 = (-(u ^ 3) + u * u + u) / 2 + 1 / 6
nc4 = (u ^ 3) / 6
DummyPoint.X = nc1 * p1(i - 1).X + nc2 * p1(i).X + nc3 * p1(i + 1).X + nc4 * p1(i + 2).X
DummyPoint.Y = nc1 * p1(i - 1).Y + nc2 * p1(i).Y + nc3 * p1(i + 1).Y + nc4 * p1(i + 2).Y
ReDim Preserve p2(UBound(p2) + 1)
p2(UBound(p2)) = DummyPoint
Next u
Next i
'Stop the jump before looking smooth. - Darthatron.
p2(0).X = (p2(1).X - CurrentX) / 2 + CurrentX
p2(0).Y = (p2(1).Y - CurrentY) / 2 + CurrentY
'End Edit
For i = 0 To UBound(p2) - 1
SilentSetCursorPos hWnd, p2(i).X, p2(i).Y
CurrentX = p2(i).X
CurrentY = p2(i).Y
Wait (Delay)
Next i
End Function
Read the comments in Cruel's original code to see what the params do... or just ask.
Download demo in attachment.
Any questions? Post.


