1111
This commit is contained in:
1 parent
89987ee139
commit
b54ecf1b6e
16 files changed
+7218
-1
No files matched your search
+5118
File diff suppressed because it is too large.
Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,37 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>luqj-damo</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>luqj-damo</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna</artifactId>
|
||||||
|
<version>5.13.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna-platform</artifactId>
|
||||||
|
<version>5.13.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jacob</groupId>
|
||||||
|
<artifactId>jacob</artifactId>
|
||||||
|
<version>1.21</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,293 @@
|
|||||||
|
package com.luqj.dm.test;
|
||||||
|
|
||||||
|
import com.jacob.activeX.ActiveXComponent;
|
||||||
|
import com.jacob.com.Dispatch;
|
||||||
|
import com.jacob.com.Variant;
|
||||||
|
import com.sun.jna.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. jdk要用x86-32位
|
||||||
|
* 2. -Djava.library.path=C:\java_ws\etl-tool\etl-tool-jacob\src\main\libs
|
||||||
|
* 3.管理员权限运行
|
||||||
|
*/
|
||||||
|
public class JacobDemo {
|
||||||
|
static final long MAX_SIZE = 10 * 1024 * 1024; // 10MB
|
||||||
|
static Memory mem = new Memory(MAX_SIZE);
|
||||||
|
|
||||||
|
// 定义接口映射 DLL
|
||||||
|
public interface DmReg extends Library {
|
||||||
|
// 对应 DLL 方法,两个参数
|
||||||
|
int SetDllPathA(String path, int is64);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
// 指定 DLL 搜索路径
|
||||||
|
NativeLibrary.addSearchPath("DmReg", "D:\\myprojects\\myEpusdt\\luqj-damo\\libs");
|
||||||
|
DmReg INSTANCE = Native.load("DmReg", DmReg.class);
|
||||||
|
// DLL 路径,比如 C:\DmSoft
|
||||||
|
String dllPath = "C:\\Users\\Administrator\\Desktop\\dm\\dm.dll";
|
||||||
|
|
||||||
|
// 调用 SetDllPathA
|
||||||
|
int result = INSTANCE.SetDllPathA(dllPath, 0);
|
||||||
|
|
||||||
|
if (result == 1) {
|
||||||
|
System.out.println("设置成功");
|
||||||
|
} else {
|
||||||
|
System.out.println("设置失败,返回值:" + result);
|
||||||
|
}
|
||||||
|
// 创建大漠对象
|
||||||
|
ActiveXComponent dm = new ActiveXComponent("dm.dmsoft");
|
||||||
|
// 获取版本
|
||||||
|
String ver = dm.invoke("Ver").toString();
|
||||||
|
System.out.println(ver);
|
||||||
|
String count = dm.invoke("GetDmCount").toString();
|
||||||
|
System.out.println(count);
|
||||||
|
dm.invoke("SetParam64ToPointer");
|
||||||
|
try {
|
||||||
|
String methodName = "Reg";
|
||||||
|
|
||||||
|
// 两个 String 参数
|
||||||
|
String str1 = "lu7213ab8fc97ec9e0277306ca66f8e6521ff6";
|
||||||
|
String str2 = "lu7213";
|
||||||
|
// 调用方法,使用 Object[] 或 Variant[]
|
||||||
|
Variant variant = Dispatch.call(dm, methodName, str1, str2);
|
||||||
|
// 输出结果
|
||||||
|
System.out.println("COM 方法返回值: " + variant.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
dmAntiBan(dm);
|
||||||
|
openNpProtection(dm);
|
||||||
|
try {
|
||||||
|
String methodName = "CapturePng";
|
||||||
|
// 调用方法,使用 Object[] 或 Variant[]
|
||||||
|
Variant variant = Dispatch.call(dm, methodName, 0, 0, 1024, 768, "C:/java_dm.png");
|
||||||
|
// 输出结果
|
||||||
|
System.out.println("COM 方法返回值: " + variant.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
//983 1058
|
||||||
|
// try {
|
||||||
|
// String methodName = "MoveToEx";
|
||||||
|
// // 调用方法,使用 Object[] 或 Variant[]
|
||||||
|
// Variant variant = Dispatch.call(dm, methodName, 983, 1058, 2, 3);
|
||||||
|
// // 输出结果
|
||||||
|
// System.out.println("MoveToEx: " + variant.toString());
|
||||||
|
// dm.invoke("Delay", 3000);
|
||||||
|
// String outResult = dm.invoke("LeftClick").toString();
|
||||||
|
// System.out.println("LeftClick: " + outResult);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
dm.invoke("SetPath", "D:\\myprojects\\myEpusdt\\luqj-damo\\src\\main\\resources");
|
||||||
|
dm.invoke("EnableShareDict", 0);
|
||||||
|
try {
|
||||||
|
String methodName = "SetDict";
|
||||||
|
// 调用方法,使用 Object[] 或 Variant[]
|
||||||
|
Variant variant = Dispatch.call(dm, methodName, 0, "test1.txt");
|
||||||
|
// 输出结果
|
||||||
|
System.out.println("COM 方法返回值: " + variant.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
count = dm.invoke("UseDict", 0).toString();
|
||||||
|
System.out.println("UseDict result = " + count);
|
||||||
|
|
||||||
|
count = dm.invoke("GetDictCount", 0).toString();
|
||||||
|
System.out.println("GetDictCount = " + count);
|
||||||
|
|
||||||
|
System.out.println("SetDisplayInput = " + dm.invoke("SetDisplayInput", "pic:D:/myprojects/myEpusdt/luqj-damo/src/main/resources/1.bmp"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
// true 表示 byRef
|
||||||
|
Variant x = new Variant(0, true);
|
||||||
|
Variant y = new Variant(0, true);
|
||||||
|
String methodName = "FindPic";
|
||||||
|
// 调用方法,使用 Object[] 或 Variant[]
|
||||||
|
Variant variant = Dispatch.call(dm, methodName, 0, 0, 703, 319, "2.bmp", "000000", 0.9, 0, x, y);
|
||||||
|
// 输出结果
|
||||||
|
System.out.println("COM 方法返回值: " + variant.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 写出BMP图片
|
||||||
|
Boolean resultSw = png2bmp("D:/myprojects/myEpusdt/luqj-damo/src/main/resources/1.png","D:/myprojects/myEpusdt/luqj-damo/src/main/resources/11.bmp");
|
||||||
|
|
||||||
|
System.out.println("resultSw="+ resultSw);
|
||||||
|
|
||||||
|
System.out.println("SetDisplayInput = " + dm.invoke("SetDisplayInput", "pic:D:/myprojects/myEpusdt/luqj-damo/src/main/resources/11.bmp"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 调用方法
|
||||||
|
Variant variant = Dispatch.call(dm, "FindPicEx", 0, 0, 733, 597, "2.bmp", "000000", 0.9, 0);
|
||||||
|
// 输出结果
|
||||||
|
System.out.println("COM 方法返回值: " + variant.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
dm.invoke("FreePic", "1.bmp");
|
||||||
|
|
||||||
|
byte[] newBytes = Files.readAllBytes(Paths.get("D:/myprojects/myEpusdt/luqj-damo/src/main/resources/1.bmp"));
|
||||||
|
mem.write(0, newBytes, 0, newBytes.length);
|
||||||
|
String param = "mem:" + Pointer.nativeValue(mem) + "," + newBytes.length;
|
||||||
|
System.out.println("SetDisplayInput = " + dm.invoke("SetDisplayInput", param));
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 调用方法
|
||||||
|
Variant variant = Dispatch.call(dm, "FindPicEx", 0, 0, 703, 319, "2.bmp", "000000", 0.9, 0);
|
||||||
|
// 输出结果
|
||||||
|
System.out.println("COM 方法返回值: " + variant.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 1. 读取 JPG
|
||||||
|
BufferedImage image = png2bmp("D:/myprojects/myEpusdt/luqj-damo/src/main/resources/1.png");
|
||||||
|
// 2. 写入内存 BMP
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(image, "BMP", baos);
|
||||||
|
byte[] bmpBytes = baos.toByteArray();
|
||||||
|
baos.close();
|
||||||
|
mem.write(0, bmpBytes, 0, bmpBytes.length);
|
||||||
|
param = "mem:" + Pointer.nativeValue(mem) + "," + bmpBytes.length;
|
||||||
|
System.out.println("SetDisplayInput = " + dm.invoke("SetDisplayInput", param));
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 调用方法
|
||||||
|
Variant variant = Dispatch.call(dm, "FindPicEx", 0, 0, 733, 597, "2.bmp", "000000", 0.9, 0);
|
||||||
|
// 输出结果
|
||||||
|
System.out.println("COM 方法返回值: " + variant.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
mem.close(); // ❌ 大漠还在用
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 开启 NP 保护盾
|
||||||
|
*
|
||||||
|
* @param dm 大漠插件 ActiveXComponent 对象
|
||||||
|
* @return 成功返回 true,失败返回 false
|
||||||
|
*/
|
||||||
|
public static boolean openNpProtection(ActiveXComponent dm) {
|
||||||
|
try {
|
||||||
|
// 调用大漠插件 DmGuard 方法,第一个参数 1 表示开启,第二个参数 "np"
|
||||||
|
int dmRet = Dispatch.call(dm, "DmGuard", 1, "np").getInt();
|
||||||
|
|
||||||
|
if (dmRet != 1) {
|
||||||
|
System.out.println("开启保护盾失败: " + dmRet);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 大漠防封设置
|
||||||
|
*/
|
||||||
|
public static void dmAntiBan(ActiveXComponent dm) {
|
||||||
|
Dispatch.call(dm, "SetKeypadDelay", "dx", 130);
|
||||||
|
Dispatch.call(dm, "SetMouseDelay", "dx", 130);
|
||||||
|
|
||||||
|
Dispatch.call(dm, "EnableRealMouse", 1, 60, 200);
|
||||||
|
Dispatch.call(dm, "EnableRealKeypad", 1);
|
||||||
|
|
||||||
|
Dispatch.call(dm, "EnableKeypadSync", 1, 200);
|
||||||
|
Dispatch.call(dm, "EnableMouseSync", 1, 200);
|
||||||
|
|
||||||
|
Dispatch.call(dm, "EnableMouseMsg", 0);
|
||||||
|
Dispatch.call(dm, "EnableKeypadMsg", 0);
|
||||||
|
}
|
||||||
|
public static BufferedImage png2bmp(String inputfile) throws IOException {
|
||||||
|
File input = new File(inputfile);
|
||||||
|
|
||||||
|
BufferedImage image = ImageIO.read(input);
|
||||||
|
|
||||||
|
// 如果 PNG 带透明通道,BMP 不支持,需要转换为 RGB
|
||||||
|
BufferedImage rgbImage = new BufferedImage(
|
||||||
|
image.getWidth(),
|
||||||
|
image.getHeight(),
|
||||||
|
BufferedImage.TYPE_INT_RGB
|
||||||
|
);
|
||||||
|
rgbImage.getGraphics().drawImage(image, 0, 0, null);
|
||||||
|
return rgbImage;
|
||||||
|
}
|
||||||
|
public static boolean png2bmp(String inputfile,String outfile) throws IOException {
|
||||||
|
File input = new File(inputfile);
|
||||||
|
File output = new File(outfile);
|
||||||
|
|
||||||
|
BufferedImage image = ImageIO.read(input);
|
||||||
|
|
||||||
|
// 如果 PNG 带透明通道,BMP 不支持,需要转换为 RGB
|
||||||
|
BufferedImage rgbImage = new BufferedImage(
|
||||||
|
image.getWidth(),
|
||||||
|
image.getHeight(),
|
||||||
|
BufferedImage.TYPE_INT_RGB
|
||||||
|
);
|
||||||
|
rgbImage.getGraphics().drawImage(image, 0, 0, null);
|
||||||
|
return ImageIO.write(rgbImage, "bmp", output);
|
||||||
|
}
|
||||||
|
public static void testExcel(String[] args) {
|
||||||
|
//System.setProperty("java.library.path", "C:\\java_ws\\etl-tool\\etl-tool-jacob\\src\\main\\libs");
|
||||||
|
// 启动 Excel
|
||||||
|
ActiveXComponent excel = new ActiveXComponent("Excel.Application");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 显示 Excel 窗口
|
||||||
|
excel.setProperty("Visible", new Variant(true));
|
||||||
|
|
||||||
|
// 获取 Workbooks 对象
|
||||||
|
Dispatch workbooks = excel.getProperty("Workbooks").toDispatch();
|
||||||
|
|
||||||
|
// 新建一个工作簿
|
||||||
|
Dispatch workbook = Dispatch.call(workbooks, "Add").toDispatch();
|
||||||
|
|
||||||
|
// 获取活动工作表
|
||||||
|
Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch();
|
||||||
|
|
||||||
|
// 写入单元格 A1
|
||||||
|
Dispatch cell = Dispatch.invoke(sheet, "Cells", Dispatch.Get,
|
||||||
|
new Object[]{1, 1}, new int[1]).toDispatch();
|
||||||
|
Dispatch.put(cell, "Value", "Hello JACOB");
|
||||||
|
|
||||||
|
// 写入单元格 B2
|
||||||
|
Dispatch.put(Dispatch.invoke(sheet, "Cells", Dispatch.Get,
|
||||||
|
new Object[]{2, 2}, new int[1]).toDispatch(), "Value", "自动化测试");
|
||||||
|
|
||||||
|
// 保存工作簿
|
||||||
|
Dispatch.call(workbook, "SaveAs", "C:\\Users\\armloop\\Desktop\\JacobDemo.xlsx");
|
||||||
|
|
||||||
|
// 关闭工作簿,不保存更改
|
||||||
|
Dispatch.call(workbook, "Close", false);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// 退出 Excel
|
||||||
|
excel.invoke("Quit");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Excel 操作完成!");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 658 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 197 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.3 KiB |
@@ -0,0 +1 @@
|
|||||||
|
2411025E5A6D4A290522A474AA927E12004000020051A9351AA0544AFF522A2544F92140200$되흙$0.0.122$12
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
|
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
|
||||||
<fastjson.version>1.2.75</fastjson.version>
|
<fastjson.version>1.2.75</fastjson.version>
|
||||||
<oshi.version>5.6.0</oshi.version>
|
<oshi.version>5.6.0</oshi.version>
|
||||||
<jna.version>5.7.0</jna.version>
|
<jna.version>5.13.0</jna.version>
|
||||||
<commons.io.version>2.5</commons.io.version>
|
<commons.io.version>2.5</commons.io.version>
|
||||||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||||
<commons.collections.version>3.2.2</commons.collections.version>
|
<commons.collections.version>3.2.2</commons.collections.version>
|
||||||
@@ -236,6 +236,7 @@
|
|||||||
<module>luqj-djl</module>
|
<module>luqj-djl</module>
|
||||||
<module>luqj-ec</module>
|
<module>luqj-ec</module>
|
||||||
<module>luqj-javacv</module>
|
<module>luqj-javacv</module>
|
||||||
|
<module>luqj-damo</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
Reference in new issue
Block a user