自动采集

wjdr
wangbing 1 year ago
parent f837faf724
commit ee3aadaa7f

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

@ -1,6 +1,7 @@
package xyz.wbsite.jmacro;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import xyz.wbsite.jmacro.base.Legend;
import xyz.wbsite.jmacro.base.ViewColor;
@ -409,6 +410,7 @@ public abstract class JMacro {
// 因为坐标取像素点是从0开始因此需要-1
int yMax = viewRect.getBottom() - pic.getHeight();
double maxSimilar = 0;
for (int y = yMin; y <= yMax; y++) {
for (int x = xMin; x <= xMax; x++) {
// 对关键点进行先期匹配,降低运算复杂度。如果关键点本身就不匹配,就没必要再去匹配小图的每一个像素点
@ -434,12 +436,16 @@ public abstract class JMacro {
}
// 计算相似度
double similar = (double) samePixels / (pic.getWidth() * pic.getHeight());
maxSimilar = Math.max(maxSimilar, similar);
if (similar >= minSimilar) {
return new ViewRect(x, y, x + pic.getWidth(), y + pic.getHeight(), similar);
}
}
}
}
if (maxSimilar > 0.5D) {
Logger.info("最大相似度{}", NumberUtil.formatPercent(maxSimilar, 0));
}
return null;
}
@ -462,7 +468,7 @@ public abstract class JMacro {
* @return
*/
public ViewRect findLegend(Legend legend, double minSimilar) {
return findPic(legend.getFile(), minSimilar);
return findLegend(getFocusRect(), legend, minSimilar);
}
/**
@ -484,6 +490,7 @@ public abstract class JMacro {
* @return
*/
public ViewRect findLegend(ViewRect rect, Legend legend, double minSimilar) {
Logger.info("查找图例:{}", legend.getName());
return findPic(rect, legend.getFile(), minSimilar);
}
@ -616,7 +623,6 @@ public abstract class JMacro {
if (result != null) {
return result;
}
delayUnstable();
}
return null;
}, seconds, TimeUnit.SECONDS);
@ -787,7 +793,7 @@ public abstract class JMacro {
BufferedImage image = ImageUtil.load(legend.getFile());
viewRect.setRight(viewRect.getLeft() + image.getWidth());
viewRect.setBottom(viewRect.getTop() + image.getHeight());
ImageUtil.show(viewRect);
//ImageUtil.show(viewRect);
return findPic(viewRect, image, minSimilar);
}

@ -10,6 +10,7 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import xyz.wbsite.jmacro.wjdr.MacroForWJDR;
import java.awt.event.KeyEvent;
import java.io.File;
@ -66,27 +67,7 @@ public class JMainApplication extends Application {
});
// 服务初始化
JMainService.init(new JMacro() {
@Override
public ViewRect focus() {
return new ViewRect(0, 0, 1920, 1080);
}
@Override
public void run() {
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"));
JMainService.init(new MacroForWJDR(), new File("legend"));
}
public static void main(String[] args) {

@ -5,6 +5,7 @@ import cn.hutool.cache.CacheUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ReUtil;
import xyz.wbsite.jmacro.util.Logger;
import java.io.File;
import java.util.List;
@ -81,6 +82,7 @@ public class Legend {
List<File> files = FileUtil.loopFiles(defaultBase, pathname -> pathname.getName().startsWith(name));
if (files.size() == 0) {
Logger.error(defaultBase.getAbsolutePath() + " not found the legend of " + name);
throw new RuntimeException(defaultBase.getAbsolutePath() + " not found the legend of " + name);
}
File file = files.get(0);

@ -219,7 +219,7 @@ public class PickLegend extends JFrame {
if (returnVal == JFileChooser.APPROVE_OPTION) {
// 默认文件
File file = jFileChooser.getSelectedFile();
String name = file.getName();
String name = file.getName().replaceAll("\\.png","");
String legendName = name.split("#")[0];
String prefix = legendName + "#";

@ -1,21 +1,16 @@
package xyz.wbsite.jmacro.wjdr;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import xyz.wbsite.jmacro.JMacro;
import xyz.wbsite.jmacro.JMainService;
import xyz.wbsite.jmacro.base.Legend;
import xyz.wbsite.jmacro.base.ViewRect;
import xyz.wbsite.jmacro.util.Logger;
import xyz.wbsite.jmacro.util.TaskUtil;
import xyz.wbsite.jmacro.wjdr.task.Task_;
import xyz.wbsite.jmacro.wjdr.task.Task_;
import xyz.wbsite.jmacro.wjdr.task.Task_线;
import xyz.wbsite.jmacro.wjdr.task.Task_;
import xyz.wbsite.jmacro.wjdr.task.Task_;
import xyz.wbsite.jmacro.wjdr.task.Task_;
import java.util.concurrent.TimeUnit;
/**
*
*
@ -67,77 +62,31 @@ public class MacroForWJDR extends JMacro {
Logger.info("任务线程开始", DateUtil.date(startTime).toString("yyyy-MM-dd HH:mm:ss"));
// 获取启动图标
Logger.info("定位启动图标");
ViewRect launch = waitAndFindPic(Legend.inflate("启动图标").getFile(), 0.9, 5);
ViewRect launch = waitAndFindPic(of("启动图标").getFile(), 0.9, 10);
if (launch != null) {
Logger.info("启动图标坐标:", launch.toString());
Logger.info("启动程序");
delayUnstable();
mouseLeftClick(launch);
delay(10 * 1000);
}
Logger.info("定位城镇");
// 定位城镇
Boolean inMain = TaskUtil.timeTask(() -> {
{ // 定位弹框,关闭弹框
delayUnstable();
ViewRect rect = findLegend(of(437, 28, 491, 106), "城镇_礼包", 0.7);
if (rect != null) {
mouseLeftClick(rect);
Logger.info("检测到充值广告弹框,关闭弹框");
}
}
{// 定位离线收益
delayUnstable();
ViewRect rect = matchLegend("城镇_离线收益", 0.9);
if (rect != null) {
mouseLeftClick(rect);
Logger.info("检测到离线收益弹框,关闭弹框");
}
}
{// 定位城镇
delayUnstable();
ViewRect rect = matchLegend("城镇", 0.9);
if (rect != null) {
Logger.info("当前区域【野外】");
Logger.info("返回区域【城镇】");
mouseLeftClick(rect);
return false;
}
}
{// 定位野外
delayUnstable();
ViewRect rect = matchLegend("野外", 0.9);
if (rect != null) {
Logger.info("当前区域【城镇】");
return true;
}
}
return false;
}, 60, TimeUnit.SECONDS);
if (!Convert.toBool(inMain, false)) {
Logger.info("未进入城镇:退出线程");
return;
}
Logger.info("进入城镇成功");
delayUnstable();
new Task_线(this, focusRect).run();
delayUnstable();
new Task_(this, focusRect).run();
// 矿场攻击检测任务
delayUnstable(1000);
new Task_(this, focusRect).run();
//
// delayUnstable();
// new Task_离线收益(this, focusRect).run();
//
// delayUnstable();
// new Task_收留避难者(this, focusRect).run();
//
// // 矿场攻击检测任务
// delayUnstable(1000);
// new Task_探险领取(this, focusRect).run();
Logger.info("启动循环任务");
while (JMainService.getInstance().run) {
new Task_(this, focusRect).run();
// 矿场攻击检测任务
delayUnstable(1000);
new Task_(this, focusRect).run();
// 避难者

@ -36,6 +36,7 @@ public abstract class BaseTask {
this.task(macro, viewRect);
Logger.info("》》》任务[{}]结束》》》", name);
} catch (Exception e) {
e.printStackTrace();
Logger.info("》》》任务[{}]异常中断》》》", name);
throw e;
}

@ -14,7 +14,7 @@ public class Task_离线收益 extends BaseTask {
public void task(JMacro macro, ViewRect viewRect) {
macro.delayUnstable();
// 定位离线收益弹框,关闭弹框
ViewRect rect = macro.waitAndMatchLegend("城镇_离线收益", 0.9);
ViewRect rect = macro.matchLegend("城镇_离线收益", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("检测到离线收益弹框,关闭弹框");

@ -0,0 +1,93 @@
package xyz.wbsite.jmacro.wjdr.task;
import xyz.wbsite.jmacro.JMacro;
import xyz.wbsite.jmacro.base.ViewRect;
import xyz.wbsite.jmacro.util.Logger;
public class Task_ extends BaseTask {
public Task_(JMacro macro, ViewRect viewRect) {
super(macro, viewRect);
}
@Override
public void task(JMacro macro, ViewRect viewRect) {
while (true) {
{// 野外返回
ViewRect rect = macro.matchLegend("野外", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("当前位置:城镇");
return;
}
}
{// 野外返回
ViewRect rect = macro.matchLegend("城镇", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("返回城镇");
}
}
{// 其他页面返回
ViewRect rect = macro.matchLegend("返回", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("返回城镇");
}
}
{ // 定位弹框,关闭弹框
ViewRect rect = macro.findLegend(macro.of(437, 28, 491, 106), "城镇_礼包", 0.7);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("关闭充值广告弹框");
}
}
{// 定位离线收益
ViewRect rect = macro.matchLegend("城镇_离线收益", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("关闭离线收益弹框");
}
}
{// 无行军队列弹框
ViewRect rect = macro.matchLegend("野外_资源无对队列", 0.9);
if (rect != null) {
macro.mouseLeftClick(macro.of(471, 250));
Logger.info("关闭弹框无对队列弹框");
}
}
{// 无行军队列弹框
ViewRect rect = macro.matchLegend("野外_搜索", 0.9);
if (rect != null) {
macro.mouseLeftClick(macro.of(253, 426));
Logger.info("关闭野外搜索弹框");
}
}
{// 一键领取弹框
ViewRect rect = macro.matchLegend("一键领取", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("一键领取");
macro.delay(500);
continue;
}
}
{// 点击任务位置退出
ViewRect rect = macro.matchLegend("点击任意位置退出", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("点击任意位置退出");
macro.delay(500);
continue;
}
}
{// 每日任务
ViewRect rect = macro.matchLegend("每日任务关闭", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("关闭每日任务关闭弹框");
}
}
}
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.