2017-10-09 120 views
0

我试图让鼠标光标从一点移动到另一点。不是在一条直线上,而是在一条曲线中。这里是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 

回答

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 
+0

'Global Const $ PI = ACos(-1)' – user4157124

+0

非常感谢您的先生。我能够在你的帮助下实现它的功能。 –

+0

@KevinRazielexŠubrt心智[发表您的解决方案](https://stackoverflow.com/q/47593934/4157124)? – user4157124