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

📄 mouseclickrequest.java

📁 局域网聊天系统的设计与实现
💻 JAVA
字号:
package remotecontrol;

import java.io.*;
import java.awt.*;

public class MouseClickRequest implements MyObject,Serializable{
	private int x;
	private int y;
	private int screenWidth;
	private int screenHeight;
	private int button;
	private int count;
	
	public MouseClickRequest(int x,int y,int screenWidth,int screenHeight,int button,int count){
		this.x=x;
		this.y=y;
		this.screenWidth=screenWidth;
		this.screenHeight=screenHeight;
		this.button=button;
		this.count=count;
	}
	public byte[] request(){
		try{
			Dimension size=Toolkit.getDefaultToolkit().getScreenSize();
			double width=size.getWidth();
			double height=size.getHeight();
			Robot robot=new Robot();
			
			robot.mouseMove((int)(this.x*(width/this.screenWidth)),(int)(this.y*(height/this.screenHeight)));
			/*width,height=>锟斤拷锟捷筿锟斤拷锟斤拷screen rectangle*/
			
			if(this.count==1){
				robot.mousePress(this.button);
				robot.mouseRelease(this.button);
			}else if(this.count>=2){
				robot.mousePress(this.button);
				robot.mouseRelease(this.button);
				robot.mousePress(this.button);
				robot.mouseRelease(this.button);
			}
		}catch(Throwable t){
			t.printStackTrace();
		}finally{
			return null;
		}
	}
	public MyObject response(){
		return null;
	}
}

⌨️ 快捷键说明

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