|
|
|
|
@ -149,13 +149,19 @@ public abstract class JMacro {
|
|
|
|
|
* @param location 坐标点
|
|
|
|
|
*/
|
|
|
|
|
public void mouseMove(Location location) {
|
|
|
|
|
// 判断当前鼠标位置和需要移动的位置是否是同一个点
|
|
|
|
|
if (Mouse.at().x == location.getX() && Mouse.at().y == location.getY()) {
|
|
|
|
|
Logger.info("鼠标位置在目标位置,不需移动");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<int[]> path = MousePathUtil.generateBezierPath(Mouse.at(), location);
|
|
|
|
|
Settings.MoveMouseDelay = 0.0f;
|
|
|
|
|
|
|
|
|
|
// 暂停点索引(-1为不暂停)
|
|
|
|
|
int pause = -1;
|
|
|
|
|
// 通过概率决断本次是否需要产生拐点(按50%概率)
|
|
|
|
|
if (RandomUtil.randomInt(0, 100) < 50) {
|
|
|
|
|
if (path.size() > 30 && RandomUtil.randomInt(0, 100) < 50) {
|
|
|
|
|
// 拐点从路径的1/3到2/3随机选择
|
|
|
|
|
int startIdx = path.size() / 3;
|
|
|
|
|
int endIdx = 2 * path.size() / 3;
|
|
|
|
|
@ -238,7 +244,7 @@ public abstract class JMacro {
|
|
|
|
|
* 鼠标右键单击
|
|
|
|
|
*/
|
|
|
|
|
public void mouseRightClick() {
|
|
|
|
|
mouseRightClick(Mouse.at());
|
|
|
|
|
Mouse.at().rightClick();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -549,10 +555,28 @@ public abstract class JMacro {
|
|
|
|
|
* @return 随机中心坐标
|
|
|
|
|
*/
|
|
|
|
|
public Location randomCenter(Region region) {
|
|
|
|
|
int x1 = Mouse.at().getX();
|
|
|
|
|
int y1 = Mouse.at().getY();
|
|
|
|
|
|
|
|
|
|
// 随机移动到区域中心附近(而非直接移动到中心)
|
|
|
|
|
Location center = region.getCenter();
|
|
|
|
|
// 得到随机移动到区域中心附近的半径
|
|
|
|
|
int radius = (int) (Math.min(region.getW(), region.getH()) / 2 * 0.9f);
|
|
|
|
|
|
|
|
|
|
// 如果半径过小,则直接返回中心点
|
|
|
|
|
if (radius <= 0) {
|
|
|
|
|
return center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 中心坐标
|
|
|
|
|
int cx = center.getX();
|
|
|
|
|
int cy = center.getY();
|
|
|
|
|
|
|
|
|
|
// 判断鼠标是否在区域中心以内
|
|
|
|
|
if (x1 >= cx - radius && x1 <= cx + radius && y1 >= cy - radius && y1 <= cy + radius) {
|
|
|
|
|
return Mouse.at();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int x = center.getX() + RandomUtil.randomInt(-radius, radius);
|
|
|
|
|
int y = center.getY() + RandomUtil.randomInt(-radius, radius);
|
|
|
|
|
return new Location(x, y);
|
|
|
|
|
|