资源简介
java开发的远程控制代码,可以开发在线教育远程控制功能
代码片段和文件信息
package steady;
import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.objectInputStream;
import java.io.objectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
public class Client {
private static Socket socket;
private static objectOutputStream OOS ;
private static objectInputStream OIS;
private static Robot robot;
/**
* 执行函数
* @param args
* @throws UnknownHostException
* @throws IOException
* @throws AWTException
* @throws InterruptedException
*/
public static void main(String[] args) throws UnknownHostException IOException AWTException InterruptedException {
// TODO Auto-generated method stub
try{
StartConnection(“s“1);
RobotThread robot= new RobotThread(OIS);
Thread t = new Thread(robot“robot“);
t.start();
while(true){
CapturePic();
}}
catch(Exception a){
OOS.close();
socket.close();
}}
public static void StartConnection(String IPint port) throws UnknownHostException IOException AWTException{
socket = new Socket(“10.10.124.47“7777);
if(socket.isConnected()){
System.out.println(“socket connected...“+socket);
}
OOS = new objectOutputStream(socket.getOutputStream());
OIS = new objectInputStream(socket.getInputStream());
}
public static void CapturePic() throws AWTException IOException{
robot= new Robot();
Message msg = null;
Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
java.awt.Dimension dm =tk.getScreenSize();
java.awt.Robot robot = new java.awt.Robot();
for (int i = 0; i < 50; i++) {
//截取指定大小的屏幕区域
Rectangle rec = new Rectangle(0 0 (int) dm.getWidth() (int) dm
.getHeight());
BufferedImage bimage = robot.createScreenCapture(rec);
//将图片保存到文件中
String filePath = “C:\\Users\\gnf\\Desktop\\logs\\screenshot“+i+“.jpeg“;
FileOutputStream fops =new FileOutputStream(filePath);
javax.imageio.ImageIO.write(bimage “jpeg“ fops);
fops.flush();
fops.close();
msg =new Message(filePath);
System.out.println(msg.getFileName());
System.out.println(“send“);
OOS.writeobject(msg);
OOS.flush();
}
}
public static void Close() throws IOException{
OOS.flush();
OOS.close();
socket.close();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 301 2016-08-18 18:52 javaControl\.classpath
..A..H. 6148 2018-12-27 15:43 javaControl\.DS_Store
..A..H. 393 2016-08-18 18:52 javaControl\.project
文件 598 2016-08-18 18:52 javaControl\.settings\org.eclipse.jdt.core.prefs
..A..H. 6148 2018-12-27 15:43 javaControl\bin\.DS_Store
文件 3669 2018-12-27 16:02 javaControl\bin\steady\Client.class
文件 1490 2018-12-27 15:46 javaControl\bin\steady\Message.class
文件 2504 2018-12-27 16:01 javaControl\bin\steady\RobotThread.class
文件 817 2018-12-27 16:02 javaControl\bin\steady\ServerwithListener$1.class
文件 701 2018-12-27 16:02 javaControl\bin\steady\ServerwithListener$2.class
文件 777 2018-12-27 16:02 javaControl\bin\steady\ServerwithListener$3.class
文件 1043 2018-12-27 16:02 javaControl\bin\steady\ServerwithListener$4.class
文件 5772 2018-12-27 16:02 javaControl\bin\steady\ServerwithListener.class
..A..H. 6148 2018-12-27 15:43 javaControl\src\.DS_Store
文件 2671 2018-12-27 16:02 javaControl\src\steady\Client.java
文件 1457 2016-08-18 23:19 javaControl\src\steady\Message.java
文件 3350 2018-12-27 16:01 javaControl\src\steady\RobotThread.java
文件 5924 2018-12-27 16:02 javaControl\src\steady\ServerwithListener.java
目录 0 2018-12-27 16:02 javaControl\bin\steady
目录 0 2018-12-27 16:02 javaControl\src\steady
...D.H. 0 2018-12-27 16:02 javaControl\.settings
目录 0 2018-12-27 16:02 javaControl\bin
目录 0 2018-12-27 16:02 javaControl\src
目录 0 2018-12-27 16:02 javaControl
----------- --------- ---------- ----- ----
49911 24
评论
共有 条评论