[source]movemouse smooth

Discussion in 'Programming General' started by slashshot007, Feb 7, 2007.

[source]movemouse smooth
  1. Unread #1 - Feb 7, 2007 at 6:38 PM
  2. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    [source]movemouse smooth

    this whole code is purely made by me except for the wait function, and probably could be alot shorter.
    recomended speed: 1-5
    Code:
    	
     Sub movemousesmooth(ByVal x As Integer, ByVal y As Integer, ByVal speed As Integer)
            Dim currentlocationx As Integer, currentlocationy As Integer, random As Integer
            currentlocationx = Windows.Forms.Cursor.Position.X
            currentlocationy = Windows.Forms.Cursor.Position.Y
            Do Until currentlocationx = x And currentlocationy = y
                If speed = 1 Then
                    random = 1
                Else
                    random = CStr(Int(Rnd() * speed))
                    If random = 0 Then random = CStr(Int(Rnd() * speed))
                End If
                If currentlocationx > x Then currentlocationx = currentlocationx - random
                If currentlocationx < x Then currentlocationx = currentlocationx + random
                If currentlocationy > y Then currentlocationy = currentlocationy - random
                If currentlocationy < y Then currentlocationy = currentlocationy + random
                Windows.Forms.Cursor.Position = New Point(currentlocationx, currentlocationy)
                Wait(0.5)
            Loop
        End Sub
    
    heres the wait function that goes with it:
    Code:
    	Public Declare Function timeGetTime Lib "winmm.dll" () As Long
    	Public Sub Wait(ByVal TimeOut As Long)
    		Dim CurrentTime As Long
    		CurrentTime = timeGetTime()
    		Do
    			System.Windows.Forms.Application.DoEvents()
    		Loop While CurrentTime + TimeOut > timeGetTime()
    	End Sub
    its probably not the least detectable one, but it still works.

    EDIT:
    Usage:

    movemousesmooth(500,500,3)
    moves to the 500,500 corrridiniates with a speed of 3. (I don't reccoment a speed over 5)
     
< Amazing tut to installing the JDK and API Documentation (lots of pics :D) | Hot keys made easy >

Users viewing this thread
1 guest


 
 
Adblock breaks this site