import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.Scanner;
public class Tset1 {
public static void main(String[] args) throws AWTException {
/*GUI*/
Robot robot = new Robot();
Scanner scanner = new Scanner(System.in);
System.out.println("点赞1,666 2");
int i3 = scanner.nextInt();
System.out.println("输入x坐标");
int i1 = scanner.nextInt();
System.out.println("输入y坐标");
int i2 = scanner.nextInt();
// 打印鼠标位置的屏幕坐标
if (i3 == 1) {
pointDz(i1, i2, robot);
} else {
/*扣666*/
robot.delay(3000);
System.out.println("鼠标移动到文本框");
pointK666(i1, i2, robot);
}
}
/*666*/
private static void pointK666(int i1, int i2, Robot robot) {
for (int i = 0; i < 10; i++) {
robot.mouseMove(i1, i2);
/*扣666*/
robot.keyPress(KeyEvent.VK_6);
robot.keyRelease(KeyEvent.VK_6);
robot.keyPress(KeyEvent.VK_6);
robot.keyRelease(KeyEvent.VK_6);
robot.keyPress(KeyEvent.VK_6);
robot.keyRelease(KeyEvent.VK_6);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
robot.delay(1000);
// 获取当前鼠标位置
Point mouseLocation = MouseInfo.getPointerInfo().getLocation();
System.out.println("Mouse Screen Coordinates: (" + mouseLocation.x + ", " + mouseLocation.y + ")");
if (i1 != mouseLocation.x) {
break;
}
}
}
/*点赞*/
private static void pointDz(int i1, int i2, Robot robot) throws AWTException {
for (int i = 0; i < 10; i++) {
robot.mouseMove(i1, i2);
/*按下*/
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
/*松开*/
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(1000);
/*滚轮向下*/
//robot.mouseWheel(1);
// 获取当前鼠标位置
Point mouseLocation = MouseInfo.getPointerInfo().getLocation();
System.out.println("Mouse Screen Coordinates: (" + mouseLocation.x + ", " + mouseLocation.y + ")");
if (i1 != mouseLocation.x) {
break;
}
Color pixelColor = robot.getPixelColor(i1, i2);
System.out.println(pixelColor.getBlue());
System.out.println(pixelColor.getRed());
System.out.println(pixelColor.getGreen());
}
}
}
java 鼠标点击和移动和键盘事件
20岁30年经验的码农2024-09-16 19:15
相关推荐
界面开发小八哥6 分钟前
更高效的Java 23开发,IntelliJ IDEA助力全面升级草莓base19 分钟前
【手写一个spring】spring源码的简单实现--容器启动Allen Bright33 分钟前
maven概述qystca35 分钟前
洛谷 B3637 最长上升子序列 C语言 记忆化搜索->‘正序‘dp编程重生之路35 分钟前
Springboot启动异常 错误: 找不到或无法加载主类 xxx.Application异常薯条不要番茄酱35 分钟前
数据结构-8.Java. 七大排序算法(中篇)今天吃饺子40 分钟前
2024年SCI一区最新改进优化算法——四参数自适应生长优化器,MATLAB代码免费获取...努力进修44 分钟前
“探索Java List的无限可能:从基础到高级应用“politeboy1 小时前
k8s启动springboot容器的时候,显示找不到application.yml文件Daniel 大东2 小时前
BugJson因为json格式问题OOM怎么办