曲线鼠标移动 [英] Curve mouse movement

查看:102
本文介绍了曲线鼠标移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使鼠标光标从一个点移动到另一点.不是直线,而是曲线.

I'm trying to make the mouse cursor move from one point to another. Not in a straight line but in a curve.

这是说明性视频.这是根据位置移动鼠标的代码:

Here is an illustrative video. Here is code that moves mouse based on the locations:

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

推荐答案

也许这可以给您一些想法.

Maybe this gives you some ideas.

#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

这篇关于曲线鼠标移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆