自动采集

wjdr
wangbing 11 months ago
parent 2b9dc91d9a
commit a3f40a9683

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

@ -151,6 +151,7 @@ public abstract class JMacro {
} }
} else { } else {
robot.mouseMove(endX, endY); robot.mouseMove(endX, endY);
delay(10);
} }
} }
@ -187,7 +188,13 @@ public abstract class JMacro {
* @param rect * @param rect
*/ */
public void mouseLeftClick(ViewPoint rect, long delay) { public void mouseLeftClick(ViewPoint rect, long delay) {
mouseMove(rect);
// 获取当前鼠标位置
Point mousePoint = MouseInfo.getPointerInfo().getLocation();
if (mousePoint.x != rect.getX() || mousePoint.y != rect.getY()) {
Logger.info("鼠标移动至[{},{}]", rect.getX(), rect.getY());
mouseMove(rect);
}
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
delay(delay); delay(delay);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
@ -380,11 +387,11 @@ public abstract class JMacro {
*/ */
public ViewRect findPic(ViewRect viewRect, File pic, double minSimilar) { public ViewRect findPic(ViewRect viewRect, File pic, double minSimilar) {
if (!pic.exists()) { if (!pic.exists()) {
Logger.error("[{}] does not exist!", pic.getAbsolutePath()); Logger.info("[{}] does not exist!", pic.getAbsolutePath());
return null; return null;
} }
if (!pic.isFile()) { if (!pic.isFile()) {
Logger.error("[{}] is not a file!", pic.getAbsolutePath()); Logger.info("[{}] is not a file!", pic.getAbsolutePath());
return null; return null;
} }
Logger.info("查找图片:{}", pic.getAbsolutePath()); Logger.info("查找图片:{}", pic.getAbsolutePath());
@ -408,7 +415,7 @@ public abstract class JMacro {
} }
// 当查找区域比图片还小时,直接返回失败 // 当查找区域比图片还小时,直接返回失败
if (viewRect.getWidth() < pic.getWidth() || viewRect.getHeight() < pic.getHeight()) { if (viewRect.getWidth() < pic.getWidth() || viewRect.getHeight() < pic.getHeight()) {
Logger.error("视口尺寸小于图片"); Logger.info("视口尺寸小于图片");
return null; return null;
} }
if (minSimilar > 1) { if (minSimilar > 1) {

@ -77,7 +77,7 @@ public class JMainService {
return false; return false;
} }
if (JMainService.getInstance().run) { if (JMainService.getInstance().run) {
Logger.error("服务已启动"); Logger.info("服务已启动");
return false; return false;
} }
@ -90,7 +90,7 @@ public class JMainService {
public static boolean stop() { public static boolean stop() {
if (!JMainService.getInstance().run) { if (!JMainService.getInstance().run) {
Logger.error("服务未启动"); Logger.info("服务未启动");
return false; return false;
} }
// 停止服务 // 停止服务
@ -109,7 +109,7 @@ public class JMainService {
@Override @Override
public void run() { public void run() {
if (macro == null) { if (macro == null) {
Logger.error("脚本未设置"); Logger.info("脚本未设置");
return; return;
} }
while (run) { while (run) {

@ -84,7 +84,7 @@ public class Legend {
List<File> files = FileUtil.loopFiles(defaultBase, pathname -> pathname.getName().startsWith(name)); List<File> files = FileUtil.loopFiles(defaultBase, pathname -> pathname.getName().startsWith(name));
if (files.size() == 0) { if (files.size() == 0) {
Logger.error(defaultBase.getAbsolutePath() + " not found the legend of " + name); Logger.info(defaultBase.getAbsolutePath() + " not found the legend of " + name);
throw new RuntimeException(defaultBase.getAbsolutePath() + " not found the legend of " + name); throw new RuntimeException(defaultBase.getAbsolutePath() + " not found the legend of " + name);
} }
File file = files.get(0); File file = files.get(0);

@ -224,7 +224,7 @@ public class PickLegend extends JFrame {
for (File file1 : files) { for (File file1 : files) {
boolean delete = file1.delete(); boolean delete = file1.delete();
if (!delete) { if (!delete) {
Logger.error("删除失败,{}", file1.getAbsolutePath()); Logger.info("删除失败,{}", file1.getAbsolutePath());
} }
} }
} }

@ -15,7 +15,7 @@ public class Task_仓库奖励领取 extends BaseTask {
isReady(); isReady();
Logger.info("打开面板"); Logger.info("打开面板");
ViewRect[] viewRects = macro.matchLegends(macro.of("城镇_面板1选中", "城镇_面板2选中"), 0.9); ViewRect[] viewRects = macro.matchLegends(macro.of("城镇_面板1选中", "城镇_面板2选中"), 0.7);
if (viewRects[0] == null && viewRects[1] == null) { if (viewRects[0] == null && viewRects[1] == null) {
Logger.info("面板未打开"); Logger.info("面板未打开");
Logger.info("检测面板打开按钮,打开面板"); Logger.info("检测面板打开按钮,打开面板");

@ -46,28 +46,52 @@ public class Task_英雄招募领取 extends BaseTask {
macro.mouseLeftClick(macro.getFocusRect()); macro.mouseLeftClick(macro.getFocusRect());
macro.delay(1000); macro.delay(1000);
Logger.info("检测任意位置继续"); {
ViewRect 退 = macro.waitAndMatchLegend("英雄招募_奖励清单", 0.9, 3); Logger.info("检测奖励清单");
if (退 != null) { ViewRect 退 = macro.waitAndMatchLegend("英雄招募_奖励清单", 0.8, 4);
Logger.info("点击任意位置退出"); if (退 != null) {
macro.mouseLeftClick(退); Logger.info("点击任意位置退出");
macro.delay(1500); macro.mouseLeftClick(退);
macro.delay(1500);
}
}
{
Logger.info("检测奖励清单");
ViewRect 退 = macro.waitAndMatchLegend("英雄招募_奖励清单", 0.8, 4);
if (退 != null) {
Logger.info("点击任意位置退出");
macro.mouseLeftClick(退);
macro.delay(1500);
}
} }
} }
} }
{ {
boolean _ = macro.matchLegendAndClick("英雄招募_史诗招募", 0.9); boolean _ = macro.matchLegendAndClick("英雄招募_史诗招募", 0.8);
if (_) { if (_) {
macro.delay(500); macro.delay(500);
macro.mouseLeftClick(macro.getFocusRect()); macro.mouseLeftClick(macro.getFocusRect());
macro.delay(1000); macro.delay(1000);
Logger.info("检测任意位置继续"); {
ViewRect 退 = macro.waitAndMatchLegend("英雄招募_奖励清单", 0.9, 3); Logger.info("检测任意位置继续");
if (退 != null) { ViewRect 退 = macro.waitAndMatchLegend("英雄招募_奖励清单", 0.9, 4);
Logger.info("点击任意位置退出"); if (退 != null) {
macro.mouseLeftClick(退); Logger.info("点击任意位置退出");
macro.delay(1500); macro.mouseLeftClick(退);
macro.delay(1500);
}
}
{
Logger.info("检测任意位置继续");
ViewRect 退 = macro.waitAndMatchLegend("英雄招募_奖励清单", 0.9, 4);
if (退 != null) {
Logger.info("点击任意位置退出");
macro.mouseLeftClick(退);
macro.delay(1500);
}
} }
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.