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
相关推荐
binishuaio2 分钟前
Java 第11天 (git版本控制器基础用法)zz.YE4 分钟前
【Java SE】StringBuffer老友@4 分钟前
aspose如何获取PPT放映页“切换”的“持续时间”值就是有点傻8 分钟前
WPF中的依赖属性洋24016 分钟前
C语言常用标准库函数进击的六角龙18 分钟前
Python中处理Excel的基本概念(如工作簿、工作表等)wrx繁星点点19 分钟前
状态模式(State Pattern)详解Upaaui22 分钟前
Aop+自定义注解实现数据字典映射zzzgd81622 分钟前
easyexcel实现自定义的策略类, 最后追加错误提示列, 自适应列宽,自动合并重复单元格, 美化表头友善的鸡蛋23 分钟前
解决:使用EasyExcel导入Excel模板时出现数据导入不进去的问题