Vb.net 拍摄隐藏控件的屏幕截图

Vb.net 拍摄隐藏控件的屏幕截图,vb.net,bitmap,webbrowser-control,screenshot,minimize,Vb.net,Bitmap,Webbrowser Control,Screenshot,Minimize,我所要做的就是能够在窗体被隐藏或最小化或webbrowser位于背景时拍摄控件(在本例中为webbrowser)的屏幕截图 我想使用计时器将其作为位图,每次计时器滴答作响时,我都想获取该控件的图像位图。当控件在顶部时,我就可以这样做 Private Function Screenshot(x1 as integer,x2 as integer,y1 as integer,y2 as integer) As Bitmap Dim bounds As Rectangle Dim sc

我所要做的就是能够在窗体被隐藏或最小化或webbrowser位于背景时拍摄控件(在本例中为
webbrowser
)的屏幕截图

我想使用计时器将其作为位图,每次计时器滴答作响时,我都想获取该控件的图像位图。当控件在顶部时,我就可以这样做

Private Function Screenshot(x1 as integer,x2 as integer,y1 as integer,y2 as integer) As Bitmap
    Dim bounds As Rectangle
    Dim screenshot As System.Drawing.Bitmap
    Dim graph As Graphics
    bounds = Screen.PrimaryScreen.Bounds
    screenshot = New System.Drawing.Bitmap(x1 - x2, y1- y2, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
    graph = Graphics.FromImage(screenshot)
    graph.CopyFromScreen(x1, y1, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
    Return screenshot
End Function

在Top上显示用于获取此屏幕截图的代码请记住,浏览器在后台时通常根本不需要渲染内容,因此尝试捕获该内容可能是徒劳的。有一个
控件。DrawToBitmap
方法,但Windows不会更新用户看不到的任何内容(当在某个东西后面或最小化时)。我显然不能将我的webbrowser放在上面,它需要放在后面。DrawToBitmap应该可以工作,即使窗口位于Z顺序的后面。