Taking a Print Screen in VB.NET
-
Anyone know how to take a Print Screen of the whole screen and then store it in an
Image
variable in VB.NET? Thanks in advance.---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ----
of which thing you want to take print screen...? i didnt get u exactly.. explain in breif... but if you want JPG photo of yr output screen, then jst press print screen key on yr keyboard. it is at topmost right. then go to paint and press controll V, and then save it.
-
of which thing you want to take print screen...? i didnt get u exactly.. explain in breif... but if you want JPG photo of yr output screen, then jst press print screen key on yr keyboard. it is at topmost right. then go to paint and press controll V, and then save it.
I know how to take a Print Screen, but I want my program to do it, i.e. take a print screen every 5 minutes (using a
Timer
object). Is there any API function or something that I can use to do this?---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ----
-
Anyone know how to take a Print Screen of the whole screen and then store it in an
Image
variable in VB.NET? Thanks in advance.---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ----
I havn't tried taking a screenshot of the whole desktop, but try looking at the Win32 functions: - gdi32.dll (function Bitblt) - user32.dll (fuinction GetWindowDC). I've tried taking a screenshot of a form before, in which case I needed to call the CreateGraphics method on a form. You'll need to call GetWindowDC to get the device context of the form, then you'll need to use BitBlt to get the graphics data from the form into a Bitmap. Try looking at this site: http://mywiki.wikidot.com/forum/t-655[^] It gives you more of an example of how todo this and could give you a direction on how to take a screenshot of the whole desktop.
-
Anyone know how to take a Print Screen of the whole screen and then store it in an
Image
variable in VB.NET? Thanks in advance.---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ----
Public G_ScreenshotPath As String = System.IO.Path.Combine(G_RuntimePath, "temp.bmp") Dim strPath As String = CaptureScreenToFile(CaptureScreenToImage(True), G_ScreenshotPath) Public Function CaptureScreenToFile(ByVal picImage As Bitmap, Optional ByVal FilePath As String = "") As String 'Get the executables path Dim file_name As String = Application.StartupPath & "\temp.bmp" If FilePath <> "" Then file_name = FilePath End If ' Save the picture as a bitmap, JPEG, or GIF. Try picImage.Save(file_name, System.Drawing.Imaging.ImageFormat.Bmp) Catch Return Nothing Exit Function End Try CaptureScreenToFile = file_name End Function Public Function CaptureScreenToImage(Optional ByVal FullScreen As Boolean = False) As Bitmap ' Captures the current screen and returns as an Image object If FullScreen = True Then ' Print Screen pressed twice here as some systems ' grab active window "accidentally" on first run. SendKeys.SendWait("{PRTSC 2}") 'Pause to let the system catch up: System.Threading.Thread.Sleep(1000) Else SendKeys.SendWait("%{PRTSC}") 'Pause to let the system catch up: System.Threading.Thread.Sleep(1000) End If Dim objData As IDataObject = Clipboard.GetDataObject() Return objData.GetData(DataFormats.Bitmap) End Function