From 186100418576c8450c8989efd345778321370f4b Mon Sep 17 00:00:00 2001 From: wangbing Date: Mon, 2 Sep 2024 17:12:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/jmacro/wjdr/JMacro.java | 2 +- .../java/com/example/jmacro/wjdr/JMainApplication.java | 4 ++-- src/main/java/com/example/jmacro/wjdr/JMainService.java | 8 ++++++-- src/main/java/com/example/jmacro/wjdr/base/Legend.java | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/example/jmacro/wjdr/JMacro.java b/src/main/java/com/example/jmacro/wjdr/JMacro.java index 169adb6..9eea5b5 100644 --- a/src/main/java/com/example/jmacro/wjdr/JMacro.java +++ b/src/main/java/com/example/jmacro/wjdr/JMacro.java @@ -397,7 +397,7 @@ public abstract class JMacro { int samePixels = 0; for (int smallY = 0; smallY < pic.getHeight(); smallY++) { for (int smallX = 0; smallX < pic.getWidth(); smallX++) { - if (ColorUtil.isSimilar(screenData[x + smallX][y + smallY], picData[smallX][smallY])) { + if (ColorUtil.isSimilar(screenData[x + smallX - xMin][y + smallY - yMin], picData[smallX][smallY])) { samePixels++; } } diff --git a/src/main/java/com/example/jmacro/wjdr/JMainApplication.java b/src/main/java/com/example/jmacro/wjdr/JMainApplication.java index a7ce499..d1b15f7 100644 --- a/src/main/java/com/example/jmacro/wjdr/JMainApplication.java +++ b/src/main/java/com/example/jmacro/wjdr/JMainApplication.java @@ -69,12 +69,12 @@ public class JMainApplication extends Application { JMainService.init(new JMacro() { @Override public ViewRect focus() { - return new ViewRect(0, 0, 200, 200); + return new ViewRect(0, 0, 1920, 1080); } @Override public void run() { - ViewRect pic = matchLegend("回收站", 0.9); + ViewRect pic = matchLegend("xinxin", 0.9); if (pic != null) { mouseLeftDoubleClick(pic); } diff --git a/src/main/java/com/example/jmacro/wjdr/JMainService.java b/src/main/java/com/example/jmacro/wjdr/JMainService.java index ad9ea18..67b23ff 100644 --- a/src/main/java/com/example/jmacro/wjdr/JMainService.java +++ b/src/main/java/com/example/jmacro/wjdr/JMainService.java @@ -117,8 +117,12 @@ public class JMainService { ThreadUtil.sleep(1000); macro.run(); } catch (Exception e) { - e.printStackTrace(); - Logger.error("异常中断"); + if ((e instanceof InterruptedException) || e.getMessage().contains(InterruptedException.class.getSimpleName())) { + // 服务停止 + } else { + e.printStackTrace(); + Logger.error("异常中断"); + } } } Logger.info("服务停止,守护线程已退出"); diff --git a/src/main/java/com/example/jmacro/wjdr/base/Legend.java b/src/main/java/com/example/jmacro/wjdr/base/Legend.java index 4713378..6fab3b5 100644 --- a/src/main/java/com/example/jmacro/wjdr/base/Legend.java +++ b/src/main/java/com/example/jmacro/wjdr/base/Legend.java @@ -89,7 +89,7 @@ public class Legend { newLegend.file = file; newLegend.name = name; - if (!name.matches("[\\S\\s]+#L[0-9]+,[0-9]+\\.png")) { + if (!file.getName().matches("[\\S\\s]+#L[0-9]+,[0-9]+\\.png")) { newLegend.location = null; } else { int x = Convert.toInt(ReUtil.get("[\\S\\s]+#L([0-9]+),[0-9]+\\.png", file.getName(), 1), 0);