找回密码
 加入
搜索
查看: 4471|回复: 8

[IE类操作] [已解决]如何对网页中指定的元素进行截图

  [复制链接]
发表于 2013-1-15 16:02:39 | 显示全部楼层 |阅读模式
本帖最后由 仙乃日 于 2013-1-15 20:49 编辑


例如要对http://www.baidu.com/中的“百度一下”这个按钮进行截图
<input class="s_btn" id="su" onmouseout="this.className='s_btn'" onmousedown="this.className='s_btn s_btn_h'" type="submit" value="百度一下"/>

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-1-15 17:52:05 | 显示全部楼层
还是我来吧
#include <IE.au3>
#include <ScreenCapture.au3>
$oIE = _IECreate("http://www.baidu.com")
$su = _IEGetObjById($oIE, "su")

;元素矩形
$dLeft = $su.getBoundingClientRect().left
$dTop = $su.getBoundingClientRect().top
$dRight = $su.getBoundingClientRect().right
$dBottom = $su.getBoundingClientRect().bottom
$hCtrl = ControlGetHandle(HWnd($oIE.hwnd), "", "Internet Explorer_Server1")

Local $tPoint = DllStructCreate($tagPOINT)
DllStructSetData($tPoint, "X", $dLeft)
DllStructSetData($tPoint, "Y", $dTop)
_WinAPI_ClientToScreen($hCtrl, $tPoint)
$x = DllStructGetData($tPoint, "X")
$y = DllStructGetData($tPoint, "Y")
_ScreenCapture_Capture(@ScriptDir & "\new.jpg", $x, $y, ($dRight - $dLeft) + $x, ($dBottom - $dTop) + $y)
ShellExecute(@ScriptDir & "\new.jpg")

评分

参与人数 1金钱 +10 收起 理由
仙乃日 + 10 谢谢 热心指导哦!

查看全部评分

发表于 2013-1-15 18:04:44 | 显示全部楼层
还是我来吧
风行者 发表于 2013-1-15 17:52



    风行者 又闪亮登场了。。。帅!
发表于 2013-1-15 19:11:27 | 显示全部楼层
本帖最后由 annybaby 于 2013-1-15 19:38 编辑

回复 2# 风行者


    表示有压力,截图得到的是一个长宽都比原来大1的小黑块~~

;;;;;;;;;;;;;;;;;;;;;已经找到原因了,IE8那个主窗体控件是
Internet Explorer_Server2

不是
Internet Explorer_Server1


其实后面的也可以直接使用UDF

#include <IE.au3>
#include <ScreenCapture.au3>
$oIE = _IECreate("http://www.baidu.com")
$su = _IEGetObjById($oIE, "su")
 
;元素矩形
$dLeft = $su.getBoundingClientRect().left
$dTop = $su.getBoundingClientRect().top
$dRight = $su.getBoundingClientRect().right
$dBottom = $su.getBoundingClientRect().bottom
$hCtrl = ControlGetHandle(HWnd($oIE.hwnd), "", "Internet Explorer_Server2")
_ScreenCapture_CaptureWnd(@ScriptDir & "\new1.jpg",$hCtrl,$dLeft,$dTop,$dRight,$dBottom)
ShellExecute(@ScriptDir & "\new1.jpg")

评分

参与人数 1金钱 +10 收起 理由
仙乃日 + 10 谢谢 热心指导哦!

查看全部评分

 楼主| 发表于 2013-1-15 20:47:36 | 显示全部楼层
本帖最后由 仙乃日 于 2013-1-15 20:48 编辑

非常感谢楼上兄弟的热心指导哦。自己使用的是IE9类别名是"Internet Explorer_Server1"。
非常奇怪的是采用ACDSee3.1或者光景魔术手查看截图左边框和上边框都缺失了,使用Win7自带
的“画图”则无此问题。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-1-16 09:41:26 | 显示全部楼层
还是我来吧
风行者 发表于 2013-1-15 17:52



    请问一下,如果这个页面的窗口比较小,按钮给遮挡在,比如要移动滚动条才能看见到,这样能在被遮挡的情况下截取到吗?
发表于 2013-1-16 21:42:38 | 显示全部楼层
仙哥好久不见!近来可好?这么有空,不用给人看病吗?
发表于 2017-5-21 14:59:12 | 显示全部楼层
不错  崇拜风行者
发表于 2017-7-31 11:34:42 | 显示全部楼层
高手啊。。学习了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 01:47 , Processed in 0.087832 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表