MoveMouse [SRC]

Topic created · 3 Mensajes · 605 Visitas
  • gyu es spiral gerrerro etc?XD mmm ai k poner las coordenadas tu?

  • Que tal UJ.Os traigo este codigo con el que podreis mover el puntero arrastrandolo de una coordenada a otra, el uso l odefinis vosotros.

    Option Explicit

    Private Type POINTAPI
    X As Long
    Y As Long
    End Type

    Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    Public Function MoveMouse(ByVal FinalX As Long, ByVal FinalY As Long, _
    Optional ByVal InitialX As Long = -1, Optional ByVal InitialY As Long = -1, Optional ByVal TimeToWait As Long = 5) As Boolean
    On Error GoTo err

    Dim PosActual As POINTAPI
    Dim I As Long
    Dim DX As Long
    Dim DY As Long
    Dim P As Double
    Dim StepVal As Integer

    GetCursorPos PosActual

    If InitialX = -1 Then InitialX = PosActual.X
    If InitialY = -1 Then InitialY = PosActual.Y

    DX = (FinalX - InitialX)
    DY = (FinalY - InitialY)

    P = (DY / DX)

    If (DX < 0) Then StepVal = -1 Else StepVal = 1

    For I = 1 To DX Step StepVal
    SetCursorPos InitialX + I, InitialY + Round((I * P))
    Sleep TimeToWait
    Next

    MoveMouse = True
    Exit Function
    err:
    End Function

    Un ejemplo de como se usa 🙂

    MoveMouse Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, 0, 0
  • La función esa es para Visual Basic, ¿no? Deberías poner el lenguaje xD