`
francisyc
  • 浏览: 5279 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

ROBOT实现HTML TO IMAGE

阅读更多
import java.awt.AWTException;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;

import javax.imageio.ImageIO;

public class TEST {
	public static void main(String[] args) throws MalformedURLException,
			IOException, URISyntaxException, AWTException {
		// 此方法仅适用于JdK1.6及以上版本
		Desktop.getDesktop().browse(
				new URL("http://google.com").toURI());
		Robot robot = new Robot();
		robot.delay(10000);
		Dimension d = new Dimension(Toolkit.getDefaultToolkit().getScreenSize());
		int width = (int) d.getWidth();
		int height = (int) d.getHeight();
		// 最大化浏览器
		robot.keyRelease(KeyEvent.VK_F11);
		robot.delay(2000);
		Image image = robot.createScreenCapture(new Rectangle(0, 0, width,
				height));
		BufferedImage bi = new BufferedImage(width, height,
				BufferedImage.TYPE_INT_RGB);
		Graphics g = bi.createGraphics();
		g.drawImage(image, 0, 0, width, height, null);
		// 保存图片
		ImageIO.write(bi, "jpg", new File("google.jpg"));
	}
}
分享到:
评论

相关推荐

    Java中利用Robot实现模拟按键

    Java中利用Robot实现模拟按键,按下和松开。

    RobotFramework中实现PageObject模式的轻量级关键字库_Python_RobotFramework.zip

    本压缩包"RobotFramework中实现PageObject模式的轻量级关键字库_Python_RobotFramework.zip"包含了使用Python语言和Robot Framework实现PageObject模式的示例库。 首先,我们需要了解PageObject模式的基本概念。...

    From Human to Robot Grasping Simulation

    From Human to Robot Grasping Simulation

    A Journey from Robot to Digital Human

    history, the general perception of a robot is a manipulatable system to mimic a human with not only the physical structure, but also the intelligence and even personality. In the early era, people ...

    A Systematic Approach to Learning Robot Programming with ROS

    ### 知识点二:《A Systematic Approach to Learning Robot Programming with ROS》书籍介绍 该书由Wyatt S. Newman撰写,CRC Press出版,是关于ROS编程的一本权威指南。书中详细介绍了如何使用ROS进行机器人编程的...

    Java Robot对象实现服务器屏幕远程监视

    Java Robot对象实现服务器屏幕远程监视

    How to make a robot

    文档标题 "How to make a robot" 指明了内容的主旨,即介绍如何从零开始构建一个机器人。该文档可能详细描述了从选购材料到组装、编程以及测试机器人的整个过程。 2. 知识产权声明与免责声明: 在描述和部分内容中...

    vscode编写RobotFramework

    vscode 编写 RobotFramework 详解 Vscode 是一个功能强大且广泛使用的代码编辑器,而 RobotFramework 是一个流行的自动化测试框架。本文将指导读者如何使用 Vscode 编写 RobotFramework 项目,包括安装 Vscode、...

    torobot舵机控制器快速测试

    torobot舵机控制器快速测试方法文档说明。

    Robot Motion Planning and Control

    How can a robot decide what motions to perform in order to achieve tasks in the physical world ? The existing industrial robot programming systems still have very limited motion planning capabilities....

    A Journey from Robot to Digital Human: Mathematical Principles and Applications

    Readers are guided through practicing and creating 3D graphics for robot arms as well as digital human models in MATLAB™, and through driving them for real-time animation. This work is intended to ...

    A Systematic Approach to Learning Robot Programming with ROS azw3

    A Systematic Approach to Learning Robot Programming with ROS 英文azw3 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

    RobotUtil_JavaRobot_JavaRobot工具类_robot_

    在这个文件中,你可以看到`Robot`实例的创建,以及上述方法的具体实现。通过使用`RobotUtil`,开发者无需直接与复杂的`Robot`类交互,而是可以直接调用这些友好的方法,从而提高代码的可读性和可维护性。 在实际...

    Robot Framework Tutorial 2016

    Robot Framework Tutorial 2016 Part 1: Installation Part 2: Keywords Part 3: Implementing Keywords in Java Part 4: Selenium2Library as a drop-in replacement for SeleniumLibrary Part 5: Integration with...

    fanuc ROBOT INTERFACE 介绍

    在Fanuc ROBOT INTERFACE中,SDK提供了一系列接口和函数,使得开发者能够编写自定义的机器人控制程序,实现对机器人运动、I/O控制、传感器数据处理等复杂功能的编程。 在提供的压缩包中,有两个主要的文档:robotif...

    WebRobot使用教程

    WebRobot是一款强大的网页自动化工具,它能够帮助用户自动执行一系列在网页上的操作,例如数据抓取、表单填写、点击按钮等,极大地提高了工作效率。在本教程中,我们将深入探讨WebRobot的安装、配置、基本操作以及...

    robot framework报告汉化(使用后log文件日志看不了)

    要实现报告的汉化,你需要找到对应的中文翻译版本或自行翻译这两个文件。通常,这些文件位于 Robot Framework 安装目录下的 `Python home` \ Lib \ site-packages \ robot \ htmldata \ rebot 目录中。 汉化步骤...

    Java中Robot类详解.pdf

    `Robot`类还可以与其他类结合使用,例如`java.awt.event.KeyEvent`和`java.awt.image.BufferedImage`,以实现更复杂的自动化任务,如键盘组合键的模拟、颜色检测等。在编写自动化脚本时,`Robot`类是一个非常强大的...

    java写的Robot

    BufferedImage image = robot.createScreenCapture(screenRect); ``` 7. **注意事项** - Robot类在某些环境中可能无法工作,比如远程桌面连接或者受限的安全环境。 - 在使用Robot进行自动化测试时,确保你的操作...

Global site tag (gtag.js) - Google Analytics