博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Watir2.0.1之——屏幕截图
阅读量:4052 次
发布时间:2019-05-25

本文共 1237 字,大约阅读时间需要 4 分钟。

     现在实现的功能是ruby的截图模块。主要是通过win32screenshot gem来完成的。

首先是安装:win32screenshot

http://rubygems.org/gems/win32screenshot

gem install win32screenshot

其次就可以来进行测试了。

require 'win32/screenshot'# Take a screenshot of the window with the specified title 用来获取特殊标题的窗口图片,比如说打开某个文件夹。Win32::Screenshot::Take.of(:window, :title => "Windows Internet Explorer").write("image.bmp")# Take a screenshot of the foreground 用来获取当前窗口的图片Win32::Screenshot::Take.of(:foreground).write("image.png")# Take a screenshot of the specified window's top-left corner's area 获取特定区域的图片Win32::Screenshot::Take.of(:window, :title => /internet/i, :area => [10, 10, 20, 20]).write("image.jpg")# Take a screenshot of the window with the specified handle Win32::Screenshot::Take.of(:window, :hwnd => 123456).write("image.gif")# Take a screenshot of the child window with the specified internal class name 可以获取子对象的图片Win32::Screenshot::Take.of(:rautomation, RAutomation::Window.new(:hwnd => 123456).                          child(:class => "Internet Explorer_Server")).write("image.png")# Use the bitmap blob for something elseimage = Win32::Screenshot::Take.of(:window, :hwnd => 123456)image.height # => height of the imageimage.width  # => width of the imageimage.bitmap # => bitmap blob

转载地址:http://jgcci.baihongyu.com/

你可能感兴趣的文章
一些socket的编程经验
查看>>
socket编程中select的使用
查看>>
可以在线C++编译的工具站点
查看>>
关于无人驾驶的过去、现在以及未来,看这篇文章就够了!
查看>>
所谓的进步和提升,就是完成认知升级
查看>>
为什么读了很多书,却学不到什么东西?
查看>>
长文干货:如何轻松应对工作中最棘手的13种场景?
查看>>
如何用好碎片化时间,让思维更有效率?
查看>>
No.174 - LeetCode1305 - 合并两个搜索树
查看>>
No.175 - LeetCode1306
查看>>
No.176 - LeetCode1309
查看>>
No.182 - LeetCode1325 - C指针的魅力
查看>>
mysql:sql alter database修改数据库字符集
查看>>
mysql:sql truncate (清除表数据)
查看>>
yuv to rgb 转换失败呀。天呀。谁来帮帮我呀。
查看>>
yuv420 format
查看>>
yuv420 还原为RGB图像
查看>>
LED恒流驱动芯片
查看>>
驱动TFT要SDRAM做为显示缓存
查看>>
使用file查看可执行文件的平台性,x86 or arm ?
查看>>