Constructor and Description |
---|
RobotUtil() |
Modifier and Type | Method and Description |
---|---|
static BufferedImage |
captureScreen()
截取全屏
|
static File |
captureScreen(File outFile)
截取全屏到文件
|
static BufferedImage |
captureScreen(Rectangle screenRect)
截屏
|
static File |
captureScreen(Rectangle screenRect,
File outFile)
截屏
|
static void |
click()
模拟单击
鼠标单击包括鼠标左键的按下和释放 |
static void |
delay()
等待指定毫秒数
|
static int |
getDelay()
获取全局默认的延迟时间
|
static Robot |
getRobot()
获取 Robot 单例实例
|
static void |
keyClick(int... keyCodes)
模拟键盘点击
包括键盘的按下和释放 |
static void |
keyPressString(String str)
打印输出指定字符串(借助剪贴板)
|
static void |
keyPressWithAlt(int key)
alt+ 按键
|
static void |
keyPressWithCtrl(int key)
ctrl+ 按键
|
static void |
keyPressWithShift(int key)
shift+ 按键
|
static void |
mouseMove(int x,
int y)
模拟鼠标移动
|
static void |
mouseWheel(int wheelAmt)
模拟鼠标滚轮滚动
|
static void |
rightClick()
模拟右键单击
鼠标单击包括鼠标右键的按下和释放 |
static void |
setDelay(int delayMillis)
设置默认的延迟时间
当按键执行完后的等待时间,也可以用ThreadUtil.sleep方法代替 |
public static void setDelay(int delayMillis)
delayMillis
- 等待毫秒数public static int getDelay()
public static void mouseMove(int x, int y)
x
- 移动到的x坐标y
- 移动到的y坐标public static void click()
public static void rightClick()
public static void mouseWheel(int wheelAmt)
wheelAmt
- 滚动数,负数表示向前滚动,正数向后滚动public static void keyClick(int... keyCodes)
keyCodes
- 按键码列表,见KeyEvent
public static void keyPressString(String str)
str
- 字符串public static void keyPressWithShift(int key)
key
- 按键public static void keyPressWithCtrl(int key)
key
- 按键public static void keyPressWithAlt(int key)
key
- 按键public static BufferedImage captureScreen()
public static File captureScreen(File outFile)
outFile
- 写出到的文件public static BufferedImage captureScreen(Rectangle screenRect)
screenRect
- 截屏的矩形区域public static File captureScreen(Rectangle screenRect, File outFile)
screenRect
- 截屏的矩形区域outFile
- 写出到的文件public static void delay()
Copyright © 2024. All rights reserved.