I’m currently trying to find a way to code human-like movement in Python without using any form of curves as they are still able to be detected for algorithmic movement. I found a post from 2 years ago by a man named Owen which depicts what looks to be near-perfect, human-like cursor movement. I’m having trouble trying to convert it, however. Anyone able provide some guidance on this?

Original Post

`**C# Code:** private static double Distance(double x1, double y1, double x2, double y2) { return Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)); } public static double Hypot(double x, double y) { return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)); } private async void HumanWindMouse(double xs, double ys, double xe, double ye, double gravity, double wind, double minWait, double maxWait, double targetArea) { double veloX = 0, veloY = 0, windX = 0, windY = 0; var msp = _mouseSpeed; var sqrt2 = Math.Sqrt(2); var sqrt3 = Math.Sqrt(3); var sqrt5 = Math.Sqrt(5); var tDist = (int)Distance(Math.Round(xs), Math.Round(ys), Math.Round(xe), Math.Round(ye)); var t = (uint)(Environment.TickCount + 10000); do { if (Environment.TickCount > t) break; var dist = Hypot(xs - xe, ys - ye); wind = Math.Min(wind, dist); if (dist < 1) dist = 1; var d = (Math.Round(Math.Round((double)tDist) * 0.3) / 7); if (d > 25) d = 25; if (d < 5) d = 5; double rCnc = rnd.Next(6); if (rCnc == 1) d = 2; double maxStep; if (d <= Math.Round(dist)) maxStep = d; else maxStep = Math.Round(dist); if (dist >= targetArea) { windX = windX / sqrt3 + (rnd.Next((int)(Math.Round(wind) * 2 + 1)) - wind) / sqrt5; windY = windY / sqrt3 + (rnd.Next((int)(Math.Round(wind) * 2 + 1)) - wind) / sqrt5; } else { windX = windX / sqrt2; windY = windY / sqrt2; } veloX = veloX + windX; veloY = veloY + windY; veloX = veloX + gravity * (xe - xs) / dist; veloY = veloY + gravity * (ye - ys) / dist; if (Hypot(veloX, veloY) > maxStep) { var randomDist = maxStep / 2.0 + rnd.Next((int)(Math.Round(maxStep) / 2)); var veloMag = Math.Sqrt(veloX * veloX + veloY * veloY); veloX = (veloX / veloMag) * randomDist; veloY = (veloY / veloMag) * randomDist; } var lastX = (int)Math.Round(xs); var lastY = (int)Math.Round(ys); xs = xs + veloX; ys = ys + veloY; if (lastX != Math.Round(xs) || (lastY != Math.Round(ys))) SetCursorPosition(new PointF((float)Math.Round(xs), (float)Math.Round(ys))); var w = (rnd.Next((int)(Math.Round((double)(100 / msp)))) * 6); if (w < 5) w = 5; w = (int)Math.Round(w * 0.9); await Task.Delay(w); } while (!(Hypot(xs - xe, ys - ye) < 1)); if (Math.Round(xe) != Math.Round(xs) || (Math.Round(ye) != Math.Round(ys))) SetCursorPosition(new PointF((float)Math.Round(xe), (float)Math.Round(ye))); _mouseSpeed = msp; } `