Bezier_MouseMove( px1, py1, px2, py2, px3, py3, Segments=5, Rel=0, Speed=2 ) { ; ------------------- ; Function by [VxE]. Successively moves the mouse from its current position to the point (px3,py3) ; through (N-1) intermediate points which lie on the cubic bezier curve described by the points ; (mx,my), (px1,py1), (px2,py2) and (px3,py3). 'Rel' should be 'true' if the points are relative to ; the mouse's current position. 'Speed' is used directly as the 'Speed' parameter of MouseMove. ; More info about Bézier curves @ http://en.wikipedia.org/wiki/B%C3%A9zier_curve ; Code Source: http://www.autohotkey.com/forum/viewtopic.php?p=374641#374641 MouseGetPos, px0, py0 If Rel px1 += px0, px2 += px0, px3 += px0, py1 += py0, py2 += py0, py3 += py0 Loop % Segments - 1 { u := 1 - t := A_Index / Segments bx := Round( px0 * u**3 + 3 * px1 * t * u**2 + 3 * px2 * u * t**2 + px3 * t**3 ) by := Round( py0 * u**3 + 3 * py1 * t * u**2 + 3 * py2 * u * t**2 + py3 * t**3 ) MouseMove, bx, by, Speed } MouseMove, px3, py3, Speed } ; Bezier_MouseMove( px1, py1, px2, py2, px3, py3, Segments=5, Rel=0, Speed=2 ) ------------------- #IfWinActive, Paint ; change this to whichever paint program you want to test in ~*b:: Click Down Bezier_MouseMove( 100, 300, 200, -300, 300, 0, 24, 1, 1 ) Click Up Return #IfWinActive esc::exitappPretty straightforward, not much to explain. Need more complexity, just use multiple calls.
Oh, and the function to simply list the intermediate points is here:
2D_Bezier( px0, py0, px1, py1, px2, py2, px3, py3, Segments ) { ; ---------------------------------- ; Function by [VxE]. Returns a newline-separated list of (N-1) points which lie on the cubic bézier ; curve described by the four input points. NOTE: the returned points will be in FLOATING POINT ; format if, and only if, px0 contains a decimal. Otherwise, the returned points will be rounded to ; integers. More info about Bézier curves @ http://en.wikipedia.org/wiki/B%C3%A9zier_curve ; NOTE: the points (px0, py0) and (px3,py3) are always omitted from the returned list. ; Code Source: http://www.autohotkey.com/forum/viewtopic.php?p=374641#374641 UseFloat := InStr( px0, "." ) Loop % Segments - 1 { u := 1 - t := A_Index / Segments bx := px0 * u**3 + 3 * px1 * t * u**2 + 3 * px2 * u * t**2 + px3 * t**3 by := py0 * u**3 + 3 * py1 * t * u**2 + 3 * py2 * u * t**2 + py3 * t**3 PointsList .= "`n" . ( UseFloat ? bx . "," . by : Round( bx ) . "," . Round( by ) ) } Return SubStr( PointsList, 2 ) } ; 2D_Bezier( px0, py0, px1, py1, px2, py2, px3, py3, Segments ) ----------------------------------