Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Taking a Print Screen in VB.NET

Taking a Print Screen in VB.NET

Scheduled Pinned Locked Moved Visual Basic
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DJLarZ
    wrote on last edited by
    #1

    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 ----

    M L D 3 Replies Last reply
    0
    • D DJLarZ

      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 ----

      M Offline
      M Offline
      manni_n
      wrote on last edited by
      #2

      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.

      D 1 Reply Last reply
      0
      • M manni_n

        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.

        D Offline
        D Offline
        DJLarZ
        wrote on last edited by
        #3

        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 ----

        1 Reply Last reply
        0
        • D DJLarZ

          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 ----

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • D DJLarZ

            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 ----

            D Offline
            D Offline
            Dean_SF
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups