⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systeminterface.java

📁 原创
💻 JAVA
字号:
package clientServer;

import java.awt.Robot;
import java.awt.image.BufferedImage;

/**
 * 对java.awt.Robot进行抽象,提供本系统与本地操作系统的借口。 响应本系统产生的鼠标键盘事件,取得桌面截图。 本类采用单态设计模式。
 * 
 * @version 2.0, 07/09/24
 * @since JDK1.6
 */
public final class SystemInterface {

	private static SystemInterface sSI = new SystemInterface();

	public static SystemInterface getInstance() {
		return sSI;
	}

	private Robot mRobot;

	// 私有的构造方法
	private SystemInterface() {
		try {
			mRobot = new Robot();
		} catch (Exception e) {
			e.printStackTrace();
			mRobot = null;
		}
	}

	/**
	 * 抓取当前桌面图像
	 * 
	 * @return 桌面图像
	 */
	public BufferedImage captureScreen() {
		return mRobot.createScreenCapture(Common.sScreenBound);

	}

	/**
	 * 处理键盘事件
	 */
	public void keyPress(int keycode) {
		mRobot.keyPress(keycode);
	}

	public void keyRelease(int keycode) {
		mRobot.keyRelease(keycode);
	}
	

	/**
	 * 鼠标事件
	 */
	public void mouseMove(int x, int y){
		mRobot.mouseMove(x, y);
	}
	
	public void mousePress(int buttons) {
		mRobot.mousePress(buttons);
	}

	public void mouseRelease(int buttons) {
		mRobot.mouseRelease(buttons);
	}
	
	public void mouseClicked(int buttons){
		mRobot.mousePress(buttons);
		mRobot.mouseRelease(buttons);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -