java 代码
- import javax.imageio.ImageIO;
- import java.awt.Rectangle;
- import java.awt.Robot;
- import java.awt.Toolkit;
- import java.awt.image.BufferedImage;
- import java.awt.Dimension;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.io.*;
- import java.util.*;
-
- public class SnapShot
- extends HttpServlet
- implements SingleThreadModel {
- private static final String CONTENT_TYPE = "image/jpeg";
-
-
- public void init() throws ServletException {
- }
-
-
- public void doGet(HttpServletRequest request, HttpServletResponse
- response) throws ServletException, IOException {
-
- response.setContentType(CONTENT_TYPE);
-
-
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
- try {
-
- {BufferedImage screenshot = (new Robot()).createScreenCapture(new
- Rectangle(0, 0, (int) d.getWidth(), (int) d.getHeight()));
- String imageFormat = "jpg";
-
- ServletOutputStream sos = response.getOutputStream();
-
- ImageIO.write(screenshot, imageFormat, sos);
- sos.close();
- response.flushBuffer();
- }
- }
- catch (Exception ex) {
- }
-
- }
-
-
- public void destroy() {
- }
- }
还有一个远程控制参考网址:
http://www.netyi.net/book-download.aspx?BookID=133a0880-41c9-4772-b422-275ed4534c6e