首先需要sikulix jar包
新建java项目
导入sikulix jar包
编写代码如下
这样电脑每隔一段时间就会去点击一下c.png这个图标
package one;
import org.sikuli.script.Screen;
public class clickMouse {
public static void main(String[] args) throws Exception {
Screen s = new Screen();
for (int i = 0; i < 5; i++) {
s.click("D:\\c.png");
//s.doubleClick();
Thread.sleep(3000);
System.out.println(System.currentTimeMillis());
}
}
}
打印log如下
[error] RobotDesktop: checkMousePosition: should be L[303,155]@S(0) - but is not!
Possible cause in case you did not touch the mouse while script was running:
Mouse actions are blocked generally or by the frontmost application.
You might try to run the SikuliX stuff as admin.
[log] CLICK on L[61,50]@S(0) (549 msec)
1671432905290
[log] CLICK on L[61,50]@S(0) (541 msec)
1671432908960
[log] CLICK on L[61,50]@S(0) (549 msec)
1671432912611
[log] CLICK on L[61,50]@S(0) (550 msec)
1671432916264
[log] CLICK on L[61,50]@S(0) (554 msec)
1671432919966
我的sikulix下载地址
Sikuli是一种新颖的图形脚本语言,或者说是一种另类的自动化测试技术。它与我们常用的自动化测试技术(工具)有很大的区别。-Java文档类资源-CSDN下载