|
|
|
@ -7,11 +7,14 @@ import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
import com.example.jmacro.wjdr.base.ScreenRect;
|
|
|
|
|
import com.example.jmacro.wjdr.task.TaskMineAttack;
|
|
|
|
|
import com.example.jmacro.wjdr.task.TaskMining;
|
|
|
|
|
import com.example.jmacro.wjdr.util.Capture;
|
|
|
|
|
import com.example.jmacro.wjdr.util.Logger;
|
|
|
|
|
import com.example.jmacro.wjdr.util.TaskUtil;
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.event.MouseAdapter;
|
|
|
|
|
import java.awt.event.MouseEvent;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.concurrent.ScheduledFuture;
|
|
|
|
@ -43,8 +46,16 @@ public class MainTask extends JFrame {
|
|
|
|
|
|
|
|
|
|
private boolean noDelay = true;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 脚本对象
|
|
|
|
|
*/
|
|
|
|
|
private JMacro jMacro;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 主屏幕区域
|
|
|
|
|
*/
|
|
|
|
|
private ScreenRect gameScreen;
|
|
|
|
|
|
|
|
|
|
public void start() throws AWTException {
|
|
|
|
|
// 加载主题
|
|
|
|
|
try {
|
|
|
|
@ -63,7 +74,25 @@ public class MainTask extends JFrame {
|
|
|
|
|
// 设置窗口的宽度和高度
|
|
|
|
|
setSize(400, 300); // 设置窗口的宽度为400像素,高度为300像素
|
|
|
|
|
// 添加一个标签作为示例内容
|
|
|
|
|
getContentPane().add(new JLabel("Hello, Swing!"));
|
|
|
|
|
JButton button = new JButton();
|
|
|
|
|
button.setText("采图");
|
|
|
|
|
button.setSize(100, 40);
|
|
|
|
|
button.addMouseListener(new MouseAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
super.mouseClicked(e);
|
|
|
|
|
if (gameScreen == null) {
|
|
|
|
|
Logger.error("请等待窗口定位");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
new Capture(gameScreen.getLeft(), gameScreen.getTop(), new File("legend"));
|
|
|
|
|
} catch (AWTException awtException) {
|
|
|
|
|
awtException.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
getContentPane().add(button);
|
|
|
|
|
// 设置窗口关闭时的操作
|
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
|
// 启动后台线程
|
|
|
|
@ -122,12 +151,7 @@ public class MainTask extends JFrame {
|
|
|
|
|
/**
|
|
|
|
|
* 主线程实现
|
|
|
|
|
*/
|
|
|
|
|
public static class MacroThread extends JMacroThread {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 主屏幕区域
|
|
|
|
|
*/
|
|
|
|
|
private ScreenRect gameScreen;
|
|
|
|
|
public class MacroThread extends JMacroThread {
|
|
|
|
|
|
|
|
|
|
public MacroThread(JMacro jMacro) {
|
|
|
|
|
super(jMacro);
|
|
|
|
|