生成鼠标渐开线随机移动轨迹 - GenerateInvoluteMouseTrajectory
函数简介
在指定半径范围内生成渐开线式随机游走轨迹,模拟自然的鼠标移动。
返回数据格式:
[{"x": 100, "y": 200}, ...]
| 字段名 | 类型 | 说明 |
|---|---|---|
| x | 整数 | 轨迹点的 X 坐标。 |
| y | 整数 | 轨迹点的 Y 坐标。 |
接口名称
GenerateInvoluteMouseTrajectory
DLL调用
long GenerateInvoluteMouseTrajectory(long ola, int startX, int startY, int radius, int stepDistance, double curvature, double noiseAmplitude);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| startX | 整数型 | 起点X坐标(中心点)。 |
| startY | 整数型 | 起点Y坐标(中心点)。 |
| radius | 整数型 | 移动半径范围(像素)。 |
| stepDistance | 整数型 | 轨迹点之间的距离(像素,建议3-10,0表示自动计算为5)。 |
| curvature | 双精度浮点数 | 曲率系数(0.5-2.0,越大越弯曲,默认1.0)。 |
| noiseAmplitude | 双精度浮点数 | 随机扰动幅度(0-5像素,默认2.0)。 |
参数详细说明
stepDistance(步距):
- 精细模式:3-5像素,轨迹平滑但点数多。
- 标准模式:5-8像素,平衡性能和效果。
- 快速模式:8-10像素,点数少但可能不够平滑。
- 传入0时自动使用默认值5像素。
curvature(曲率系数):
- 0.5:轻微弯曲,接近直线。
- 1.0:标准弯曲(推荐)。
- 1.5-2.0:高度弯曲,更自然随机。
noiseAmplitude(扰动幅度):
- 0-1.0:轻微抖动。
- 1.0-3.0:标准抖动,模拟人手(推荐)。
- 3.0-5.0:明显抖动。
示例
long instance = CreateCOLAPlugInterFace();
// 生成标准渐开线随机轨迹(中心点500,300,半径100像素)
long ret = GenerateInvoluteMouseTrajectory(instance, 500, 300, 100, 5, 1.0, 2.0);
if (ret != 0) {
// 解析JSON数据并使用轨迹点
FreeStringPtr(ret);
}
DestroyCOLAPlugInterFace(instance);
返回值
字符串指针地址,包含JSON格式的轨迹点数组数据。返回 0 表示失败。
注意事项
- DLL调用返回字符串指针地址,需要调用 FreeStringPtr 接口释放内存。
