PYTHON 3 - Human-Like Mouse Movement [on hold]

Multi tool use
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;
}
python python-3.x
New contributor
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
put on hold as off-topic by Hosch250, l0b0, Sᴀᴍ Onᴇᴌᴀ, 200_success, Ludisposed 1 hour ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Hosch250, l0b0, Sᴀᴍ Onᴇᴌᴀ, 200_success, Ludisposed
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
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;
}
python python-3.x
New contributor
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
put on hold as off-topic by Hosch250, l0b0, Sᴀᴍ Onᴇᴌᴀ, 200_success, Ludisposed 1 hour ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Hosch250, l0b0, Sᴀᴍ Onᴇᴌᴀ, 200_success, Ludisposed
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
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;
}
python python-3.x
New contributor
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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;
}
python python-3.x
python python-3.x
New contributor
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 hours ago


Cuch
11
11
New contributor
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Cuch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
put on hold as off-topic by Hosch250, l0b0, Sᴀᴍ Onᴇᴌᴀ, 200_success, Ludisposed 1 hour ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Hosch250, l0b0, Sᴀᴍ Onᴇᴌᴀ, 200_success, Ludisposed
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by Hosch250, l0b0, Sᴀᴍ Onᴇᴌᴀ, 200_success, Ludisposed 1 hour ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Hosch250, l0b0, Sᴀᴍ Onᴇᴌᴀ, 200_success, Ludisposed
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
fSH,JKTW,YFXlWfhLaGKvQVjC VDJYtay QMVujUPB,tMDT,yUr,7Qzza nGeFVJqwlrMPT98T,gQSRopJgEJMKgL