找回密码
 加入
搜索
查看: 2636|回复: 11

[图形处理] 如何获取一个隐藏窗口的截图?

    [复制链接]
发表于 2018-3-9 09:41:20 | 显示全部楼层 |阅读模式
隐藏窗口后就不影响工作了。这样可以干别的事情了。但是用截屏函数只能截取到桌面的左边了。对IE的自动网页填表就没法识别验证码了。求教了。
发表于 2018-3-13 01:04:08 | 显示全部楼层
_ScreenCapture_CaptureWnd
 楼主| 发表于 2018-3-13 04:48:51 | 显示全部楼层
谢谢我测试下试试
 楼主| 发表于 2018-3-16 15:30:04 | 显示全部楼层
用_ScreenCapture_CaptureWnd无法获取隐藏的ie截图
发表于 2018-3-21 15:14:49 | 显示全部楼层
不会隐藏窗口截图,但是给你一个思路……移动窗口到显示范围外,然后显示窗口截图,至于要不要再隐藏移动回来那就是你的事情了……  不过能达到你要的不影响你干其他事情的目的
 楼主| 发表于 2018-3-27 08:37:07 | 显示全部楼层
好办法啦。谢谢。我试试看。
 楼主| 发表于 2018-3-29 16:27:11 | 显示全部楼层
实验了几天没有特别好的方法,实现的代码略显难懂,而且需要激活一次窗口
发表于 2018-3-29 19:08:28 | 显示全部楼层
把代码发上来啊~   光这么说只能给你思路,给不了代码~
 楼主| 发表于 2018-3-29 20:41:35 | 显示全部楼层
明天放代码
 楼主| 发表于 2018-3-30 09:43:35 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#include <array.au3>
#include <GDIPlus.au3>



local $url="http://WWW.SOHU.COM"
local $title="[CLASS:IEFrame]"
local $hWnd=NULL
local $hWnd2=NULL
_GDIPlus_Startup()



Run(@programFilesDir & "\Internet Explorer\iexplore.exe " & $url)

WinWait($title, "", 10)

WinSetState($title, "", @SW_HIDE)


do
$hWnd2=WinGetHandle($title)
until $hWnd2



WinMove($hWnd2,"",3000,3000,1600,800)
WinSetState($hWnd2, "", @SW_SHOW)
Sleep(100)



$hWnd=ControlGetHandle($title,"","Internet Explorer_Server1")




Local $iSize = WinGetPos($hWnd)



local $hPic=$hWnd

Local $hDC = _WinAPI_GetDC($hPic);取得控件的环境句柄
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC);创建兼容的内存环境,返回内存环境句柄
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iSize[2], $iSize[3]);创建画布,返回画布句柄
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap);把画布放到内存环境里去,返回之前的对象的句柄

Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC);再创建一个内存环境。
Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $iSize[2], $iSize[3]);再创建一个画布。
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp);然后把第二画布放到第二个内存环境里去。
_WinAPI_PrintWindow($hWnd, $hSrcDC);复制程序窗口到第2个内存环境中去。
_WinAPI_BitBlt($hDestDC, 0, 0, $iSize[2], $iSize[3], $hSrcDC, 0, 0, $MERGECOPY)
;从第二个内存环境中传输位图信息到第一个内存环境。

_WinAPI_ReleaseDC($hPic, $hDC);释放控件的环境句柄
_WinAPI_SelectObject($hDestDC, $hDestSv);还原内存环境
_WinAPI_SelectObject($hSrcDC, $hSrcSv);;还原内存环境
_WinAPI_DeleteDC($hDestDC);删除内存环境句柄
_WinAPI_DeleteDC($hSrcDC);删除内存环境句柄
_WinAPI_DeleteObject($hBmp);删除第二个位图

    local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; 创建 24 位位图克隆
    local $iX = _GDIPlus_ImageGetWidth($hImage)
    local $iY = _GDIPlus_ImageGetHeight($hImage)
    local $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, 1000, 700, $GDIP_PXF24RGB)
        _GDIPlus_ImageSaveToFile($hClone, @desktopDir & "\GDIPlus_Image.bmp")


_GDIPlus_ImageDispose($hClone)
_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()

while ProcessExists("iexplore.exe")   
ProcessClose("iexplore.exe")  
WEnd
exit
 楼主| 发表于 2018-3-30 09:46:05 | 显示全部楼层
大家测试下,我没办法做到一上来就隐藏窗口,还请指教。谢谢。里面的注释代码是我自己加上去的。翻译的不对的请指正。或者代码本省还可以省略也请指正。谢谢。
 楼主| 发表于 2018-3-30 10:01:34 | 显示全部楼层
WinWait($title, "", 10)
这句最好换成真实的网页TITLE,不要用类,否则可能截到黑屏,我就不修改了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-20 19:34 , Processed in 0.078094 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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