Results 1 to 5 of 5

Thread: Moving the mouse around automatically

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Posts
    117
    Does anyone know how to move the mouse around automatically, and stop when it comes over a particular piece of text or an image.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'an example of how to move a mouse using API
    '
    '=================================================
    'Bas Module Code
    
    Option Explicit
    
    Public Type POINTAPI
        x As Long
        y As Long
    End Type
    
    Public Declare Function ClientToScreen Lib _
    "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) _
    As Long
    
    Declare Function SetCursorPos Lib "user32" _
    (ByVal x As Long, ByVal y As Long) As Long
    
    '===================================================
    'Form Code
    
    Option Explicit
    
    Sub MoveMouse(x As Single, y As Single)
    
        Dim sPoint As POINTAPI
    
        sPoint.x = x
        sPoint.y = y
        
        ClientToScreen hwnd, sPoint
        SetCursorPos sPoint.x, sPoint.y
    
    End Sub
    
    Private Sub Command1_Click()
        MoveMouse Target.Left + Target.Width / 2, _
                  Target.Top + Target.Height / 2
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Hyperactive Member Juan Carlos Rey's Avatar
    Join Date
    Aug 1999
    Location
    Mendoza, Argentina
    Posts
    301

    Talking Warning

    Be careful, dude.
    I wouldn´t like my mouse roaming all over the desk!

    (lol)
    Combat poverty: kill a poor!!

  4. #4
    Addicted Member cwm's Avatar
    Join Date
    Mar 2000
    Posts
    133
    hmm... would that little roaming mouse be looking for a link to click by chance?
    Generic vb 5

    Private Sub WakeMyAssUp( As Boolean)
    If Then : = False
    End Sub

  5. #5
    Guest
    To give the mouse a bit of an effect:

    Code:
    Declare Function SetCursorPos Lib "user32" _
    (ByVal x As Long, ByVal y As Long) As Long
    
    Private Declare Sub Sleep Lib "kernel32" _
    (ByVal dwMilliseconds As Long)
    
    Public Type POINTAPI
        x As Long
        y As Long
    End Type
    
    Private Sub Command1_Click()
    For i = 100 To 300
    SetCursorPos i, i: Sleep 10
    DoEvents
    Next i
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width