SilentMoveMouseCC [Function]

Discussion in 'Programming General' started by Darthatron, May 29, 2009.

SilentMoveMouseCC [Function]
  1. Unread #1 - May 29, 2009 at 11:51 PM
  2. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    SilentMoveMouseCC [Function]

    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.
    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.
     

    Attached Files:

  3. Unread #2 - May 30, 2009 at 6:43 AM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    SilentMoveMouseCC [Function]

    So, per example, let's just say you wanted to silent click for a RuneScape bot, like RSbot, but you get banned if RS doesn't detect that the "mouse" actually hasn't moved. Does this tell the client that the "mouse" has moved, to avoid being banned for silent clicking?
     
  5. Unread #3 - May 30, 2009 at 7:11 AM
  6. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    SilentMoveMouseCC [Function]

    That is correct Swan. This function sends messages to the RuneScape window telling it the mouse is moving, even though it's actually still in control of the user.
     
  7. Unread #4 - May 30, 2009 at 4:44 PM
  8. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    SilentMoveMouseCC [Function]

    Swan asked you a question. Answer it.

    (I would say yes and no Swan.. it doesn't tell the client specifically but it simulates a mouse click and I don't think the WinAPI differentiates the SendMessage mouse movements/clicks from regular ones)
     
  9. Unread #5 - May 30, 2009 at 5:40 PM
  10. Stuart
    Joined:
    May 5, 2005
    Posts:
    1,580
    Referrals:
    2
    Sythe Gold:
    10

    Stuart Guru
    Banned

    SilentMoveMouseCC [Function]

    The only way to be sure would be to make a detection system equivilant to the system jagex has and then try it.
     
  11. Unread #6 - May 31, 2009 at 9:28 AM
  12. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    SilentMoveMouseCC [Function]

    Until we can get our hands on such a system we can really only assume this is efficient. :\
     
  13. Unread #7 - May 31, 2009 at 3:06 PM
  14. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    SilentMoveMouseCC [Function]

    Couldn't you just load a modified client in a JFrame and try sending it things with this and check to see if the mouseEvent stuff works properly? Or must this load runescape in the very same program?
     
  15. Unread #8 - Jun 1, 2009 at 3:59 AM
  16. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    SilentMoveMouseCC [Function]

    It can on any window as long as it has a handle. However Java isn't one of my strong points... Any help would be good. ^^
     
  17. Unread #9 - Jun 1, 2009 at 9:37 AM
  18. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    SilentMoveMouseCC [Function]

    Hmm...kinda hard to explain. Perhaps you could create a .exe from this and I test it and get back with the results?
     
< [Tutorial Series] Learn C# from Scratch | Need a coder for a start up website business >

Users viewing this thread
1 guest


 
 
Adblock breaks this site