2017-10-09 156 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