All I want to do is to be able to take a screenshot of a control (in this instance a webbrowser
) while the form is hidden-minimized or the webbrowser is on the background.
I want to take it as a bitmap using a timer, every time timer ticks I want to take an image-bitmap of that control. I'm abled to do it when the control is on the top.
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