From 496334a3a3b31e20867f98845ba1c8dc9d64f137 Mon Sep 17 00:00:00 2001 From: wangbing Date: Thu, 5 Sep 2024 11:14:43 +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 --- .../java/com/example/jmacro/wjdr/JMacro.java | 9 +++++++++ .../example/jmacro/wjdr/JMainApplication.java | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/jmacro/wjdr/JMacro.java b/src/main/java/com/example/jmacro/wjdr/JMacro.java index 4150447..a41a86b 100644 --- a/src/main/java/com/example/jmacro/wjdr/JMacro.java +++ b/src/main/java/com/example/jmacro/wjdr/JMacro.java @@ -872,6 +872,15 @@ public abstract class JMacro { return Convert.toBool(result, false); } + /** + * 获取图例 + * + * @return 图例 + */ + public Legend of(String legend) { + return Legend.inflate(legend); + } + /** * 将相对坐标转为绝对坐标 * diff --git a/src/main/java/com/example/jmacro/wjdr/JMainApplication.java b/src/main/java/com/example/jmacro/wjdr/JMainApplication.java index 78f2152..05746f3 100644 --- a/src/main/java/com/example/jmacro/wjdr/JMainApplication.java +++ b/src/main/java/com/example/jmacro/wjdr/JMainApplication.java @@ -1,6 +1,6 @@ package com.example.jmacro.wjdr; -import com.example.jmacro.wjdr.base.ViewPoint; +import com.example.jmacro.wjdr.base.Legend; import com.example.jmacro.wjdr.base.ViewRect; import com.example.jmacro.wjdr.ui.FXMLUtil; import com.example.jmacro.wjdr.util.Logger; @@ -70,13 +70,21 @@ public class JMainApplication extends Application { JMainService.init(new JMacro() { @Override public ViewRect focus() { - return new ViewRect(0, 0, 500, 500); + return new ViewRect(0, 0, 1920, 1080); } @Override public void run() { - findLegend(of(0,0,159,168), "电脑", 0.99); - findLegend(of(100,100,200,200), "电脑2", 0.99); + ViewRect 电脑 = findLegend(of(0, 0, 159, 168), "电脑", 0.99); + if (电脑 == null) { + return; + } + mouseLeftDoubleClick(电脑); + ViewRect 关闭 = waitAndFindLegend(of("关闭"), 0.99, 10); + if (关闭 == null) { + return; + } + mouseLeftClick(关闭); } }, new File("legend")); }