parent
35af343caf
commit
db389cb76d
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 3.8 KiB |
@ -1,49 +0,0 @@
|
||||
package com.example.jmacro.wjdr;
|
||||
|
||||
import com.example.jmacro.wjdr.base.ViewRect;
|
||||
import com.example.jmacro.wjdr.util.TaskUtil;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 脚本线程
|
||||
*
|
||||
* @author wangbing
|
||||
* @version 0.0.1
|
||||
* @since 1.8
|
||||
*/
|
||||
public abstract class JMacroThread implements Runnable {
|
||||
|
||||
/**
|
||||
* 脚本对象
|
||||
*/
|
||||
protected JMacro macro;
|
||||
|
||||
/**
|
||||
* 视口区域
|
||||
*/
|
||||
protected ViewRect viewRect;
|
||||
|
||||
public JMacroThread(JMacro macro) {
|
||||
this.macro = macro;
|
||||
TaskUtil.asyncTask(() -> {
|
||||
viewRect = TaskUtil.timeTask(this::location, 10, TimeUnit.SECONDS);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取视口区域
|
||||
*
|
||||
* @return 视口区域
|
||||
*/
|
||||
public abstract ViewRect location();
|
||||
|
||||
public ViewRect getViewRect() {
|
||||
return viewRect;
|
||||
}
|
||||
|
||||
public JMacro getMacro() {
|
||||
return macro;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.example.jmacro.wjdr.demo.task;
|
||||
|
||||
import com.example.jmacro.wjdr.JMacro;
|
||||
import com.example.jmacro.wjdr.base.ViewRect;
|
||||
import com.example.jmacro.wjdr.util.Logger;
|
||||
|
||||
public class Task_收留避难者 extends BaseTask {
|
||||
|
||||
public Task_收留避难者(JMacro macro, ViewRect viewRect) {
|
||||
super(macro, viewRect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void task(JMacro macro, ViewRect viewRect) {
|
||||
ViewRect rect = macro.waitAndMatchPic(viewRect, "城镇_避难者_L3,174", 0.9);
|
||||
if (rect == null) {
|
||||
Logger.info("未发现避难者");
|
||||
return;
|
||||
}
|
||||
Logger.info("发现避难者");
|
||||
|
||||
Logger.info("收留避难者");
|
||||
macro.mouseLeftClick(rect);
|
||||
|
||||
macro.delayUnstable();
|
||||
ViewRect rect1 = macro.waitAndMatchPic(viewRect, "城镇_欢迎新成员_L199,773", 0.9);
|
||||
if (rect1 == null) {
|
||||
Logger.info("收留避难者异常");
|
||||
return;
|
||||
}
|
||||
|
||||
macro.delayUnstable();
|
||||
Logger.info("欢迎新成员");
|
||||
macro.mouseLeftClick(rect1);
|
||||
|
||||
macro.delayUnstable();
|
||||
Logger.info("返回城镇");
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package com.example.jmacro.wjdr.util;
|
||||
package com.example.jmacro.wjdr.tool;
|
||||
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.log.StaticLog;
|
||||
import com.example.jmacro.wjdr.util.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
Loading…
Reference in new issue