曲线鼠标移动

时间:2017-10-09 17:39:17

标签: mouse bots autoit

我试图让鼠标光标从一个点移动到另一个点。不是直线而是曲线。

这是an illustrative video。以下是根据位置移动鼠标的代码:

Func smoothmove($coords, $j, $firstms);make mouse move to the note
    Dim $currcoord[3]
    Dim $diff[3]
    Dim $pixelsptms[3]
    If $j > 1 Then
        If Mod($coords[$j - 1][7][1], 2) = 0 Then
            $currcoord[1] = $coords[$j - 1][1][1]
            $currcoord[2] = $coords[$j - 1][2][1]
        Else
            $currcoord[1] = $coords[$j - 1][1][$coords[$j - 1][1][0]]
            $currcoord[2] = $coords[$j - 1][2][$coords[$j - 1][2][0]]
        EndIf
    Else
        $currcoord[1] = MouseGetPos(0)
        $currcoord[2] = MouseGetPos(1)
    EndIf
    If $coords[$j][1][1] = $currcoord[1] Then
        If $coords[$j][2][1] = $currcoord[2] Then Return 1
    EndIf
    If $coords[$j][3][1] <= $firstms Then Return 1
    $diff[1] = $coords[$j][1][1] - $currcoord[1]
    $diff[2] = $coords[$j][2][1] - $currcoord[2]
    $pixelsptms[1] = ($diff[1] / ($coords[$j][3][1] - $firstms)) * 12
    $pixelsptms[2] = ($diff[2] / ($coords[$j][3][1] - $firstms)) * 12
    Dim $ready[5]
    $ready[1] = 2
    $ready[2] = 3
    $ready[3] = 2
    $ready[4] = 3
    $firstms += 12
    $count = 0
    While 1
        DllCall($osumap[0], 'int', 'ReadProcessMemory', 'int', $osumap[1], 'int', $address[2], 'ptr', $bufferptr, 'int', $buffersize, 'int', '')
        $ms = DllStructGetData($buffer, 1)
        If $ms >= $coords[$j][3][1] Then Return 1
        If $pixelsptms[1] < 0 Then
            If $currcoord[1] <= $coords[$j][1][1] Then
                $currcoord[1] = $coords[$j][1][1]
                $ready[3] = 1
                $pixelsptms[1] = 0
            EndIf
        Else
            If $currcoord[1] >= $coords[$j][1][1] Then
                $currcoord[1] = $coords[$j][1][1]
                $ready[3] = 1
                $pixelsptms[1] = 0
            EndIf
        EndIf
        If $pixelsptms[2] < 0 Then
            If $currcoord[2] <= $coords[$j][2][1] Then
                $currcoord[2] = $coords[$j][2][1]
                $ready[4] = 1
                $pixelsptms[2] = 0
            EndIf
        Else
            If $currcoord[2] >= $coords[$j][2][1] Then
                $currcoord[2] = $coords[$j][2][1]
                $ready[4] = 1
                $pixelsptms[2] = 0
            EndIf
        EndIf
        If $ready[3] = $ready[4] Then Return -1
        If $ms >= $firstms Then
            $currcoord[1] += $pixelsptms[1]
            $currcoord[2] += $pixelsptms[2]
            $firstms += 12

            MouseMove($currcoord[1], $currcoord[2], 0)

        EndIf
    WEnd
EndFunc

1 个答案:

答案 0 :(得分:2)

也许这会给你一些想法。

#include <math.au3>
HotKeySet("{ESC}", "esc")
Global Const $PI = 3.1415926535897932384626433832795
Dim $t
Dim $expr
For $theta = 0 To 924 * $PI ;ALSO MAKE THE LOOP GO LONGER
    $t = _Radian($theta)
    $expr = Exp(Cos($t)) - 2 * Cos(4 * $t) - Sin($t / 12) ^ 5
    $x = 400 + 100 * Cos($t) * $expr
    $y = 400 + 100 * Sin($t) * $expr
    ConsoleWrite($x & "," & $y & @LF) ;Use for debugging with SciTE
    MouseMove($x, $y, 1)
Next

Func esc()
    Exit 0
EndFunc   ;==>esc