|
|
|
@ -14,7 +14,6 @@ import org.sikuli.script.Region;
|
|
|
|
import org.sikuli.script.Screen;
|
|
|
|
import org.sikuli.script.Screen;
|
|
|
|
import xyz.wbsite.jmacro.base.ColorLocation;
|
|
|
|
import xyz.wbsite.jmacro.base.ColorLocation;
|
|
|
|
import xyz.wbsite.jmacro.base.Legend;
|
|
|
|
import xyz.wbsite.jmacro.base.Legend;
|
|
|
|
import xyz.wbsite.jmacro.util.ImageUtil;
|
|
|
|
|
|
|
|
import xyz.wbsite.jmacro.util.Logger;
|
|
|
|
import xyz.wbsite.jmacro.util.Logger;
|
|
|
|
import xyz.wbsite.jmacro.util.MousePathUtil;
|
|
|
|
import xyz.wbsite.jmacro.util.MousePathUtil;
|
|
|
|
import xyz.wbsite.jmacro.util.TaskUtil;
|
|
|
|
import xyz.wbsite.jmacro.util.TaskUtil;
|
|
|
|
@ -22,7 +21,6 @@ import xyz.wbsite.jmacro.util.TaskUtil;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.datatransfer.Clipboard;
|
|
|
|
import java.awt.datatransfer.Clipboard;
|
|
|
|
import java.awt.datatransfer.StringSelection;
|
|
|
|
import java.awt.datatransfer.StringSelection;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
@ -182,13 +180,7 @@ public abstract class JMacro {
|
|
|
|
* @param region 区域
|
|
|
|
* @param region 区域
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void mouseMove(Region region) {
|
|
|
|
public void mouseMove(Region region) {
|
|
|
|
// 随机移动到区域中心附近(而非直接移动到中心)
|
|
|
|
mouseMove(randomCenter(region));
|
|
|
|
Location center = region.getCenter();
|
|
|
|
|
|
|
|
// 得到随机移动到区域中心附近的半径
|
|
|
|
|
|
|
|
int radius = (int) (Math.min(region.getW(), region.getH()) / 2 * 0.9f);
|
|
|
|
|
|
|
|
int x = center.getX() + RandomUtil.randomInt(-radius, radius);
|
|
|
|
|
|
|
|
int y = center.getY() + RandomUtil.randomInt(-radius, radius);
|
|
|
|
|
|
|
|
mouseMove(new Location(x, y));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -204,7 +196,7 @@ public abstract class JMacro {
|
|
|
|
* @param region 区域
|
|
|
|
* @param region 区域
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void mouseLeftClick(Region region) {
|
|
|
|
public void mouseLeftClick(Region region) {
|
|
|
|
mouseMove(region.getCenter());
|
|
|
|
mouseMove(randomCenter(region));
|
|
|
|
mouseLeftClick();
|
|
|
|
mouseLeftClick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -229,7 +221,7 @@ public abstract class JMacro {
|
|
|
|
* 鼠标左键双击
|
|
|
|
* 鼠标左键双击
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void mouseLeftDoubleClick(Region region) {
|
|
|
|
public void mouseLeftDoubleClick(Region region) {
|
|
|
|
mouseMove(region.getCenter());
|
|
|
|
mouseMove(randomCenter(region));
|
|
|
|
mouseLeftDoubleClick();
|
|
|
|
mouseLeftDoubleClick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -254,13 +246,7 @@ public abstract class JMacro {
|
|
|
|
* @param region 区域
|
|
|
|
* @param region 区域
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void mouseRightClick(Region region) {
|
|
|
|
public void mouseRightClick(Region region) {
|
|
|
|
// 随机移动到区域中心附近(而非直接移动到中心)
|
|
|
|
mouseMove(randomCenter(region));
|
|
|
|
Location center = region.getCenter();
|
|
|
|
|
|
|
|
// 得到随机移动到区域中心附近的半径
|
|
|
|
|
|
|
|
int radius = (int) (Math.min(region.getW(), region.getH()) / 2 * 0.9f);
|
|
|
|
|
|
|
|
int x = center.getX() + RandomUtil.randomInt(-radius, radius);
|
|
|
|
|
|
|
|
int y = center.getY() + RandomUtil.randomInt(-radius, radius);
|
|
|
|
|
|
|
|
mouseMove(new Location(x, y));
|
|
|
|
|
|
|
|
mouseRightClick();
|
|
|
|
mouseRightClick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -510,4 +496,20 @@ public abstract class JMacro {
|
|
|
|
public ColorLocation of(Location relativePoint, String hexColor) {
|
|
|
|
public ColorLocation of(Location relativePoint, String hexColor) {
|
|
|
|
return of(relativePoint.getX(), relativePoint.getY(), hexColor);
|
|
|
|
return of(relativePoint.getX(), relativePoint.getY(), hexColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取随机中心坐标
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param region 区域
|
|
|
|
|
|
|
|
* @return 随机中心坐标
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public Location randomCenter(Region region) {
|
|
|
|
|
|
|
|
// 随机移动到区域中心附近(而非直接移动到中心)
|
|
|
|
|
|
|
|
Location center = region.getCenter();
|
|
|
|
|
|
|
|
// 得到随机移动到区域中心附近的半径
|
|
|
|
|
|
|
|
int radius = (int) (Math.min(region.getW(), region.getH()) / 2 * 0.9f);
|
|
|
|
|
|
|
|
int x = center.getX() + RandomUtil.randomInt(-radius, radius);
|
|
|
|
|
|
|
|
int y = center.getY() + RandomUtil.randomInt(-radius, radius);
|
|
|
|
|
|
|
|
return new Location(x, y);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|