VB.NET Window Screen Capture (ALT+PRINTSCREEN)

前端 未结 5 1395
渐次进展
渐次进展 2021-01-03 02:25

I found that code somewhere and I find it quite useful but I would like to find a way to make it work so it capture only the given window target. Maybe with a processID or W

相关标签:
5条回答
  • 2021-01-03 02:52

    Look at this Capture screenshot of active window? Instead of this.Handle (current window) you may insert a handle of any other window (using WinAPI functions like FindWindow)

    0 讨论(0)
  • 2021-01-03 02:52

    The easiest way to do it, though it's a hack, is this:

    SendKeys.Send("{PRTSC}")
    Dim Screenshot As Image = Clipboard.GetImage()
    Screenshot.Save("c:\ScreenShot.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
    
    0 讨论(0)
  • 2021-01-03 03:01

    This will give you the Alt + Printscreen, showing only front most application.

    SendKeys.Send("%{PRTSC}") 
    

    Then continue the normal way:

    Dim Screenshot As Image = Clipboard.GetImage()
    Screenshot.Save("c:\ScreenShot.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
    
    0 讨论(0)
  • 2021-01-03 03:05

    This works in vb.net2.0. I just used it. Here is the source code.

        Dim SC As New ScreenShot.ScreenCapture
    
        'captures entire desktop straight to file
        SC.CaptureScreenToFile("c:\accops\test\desktop2.jpg", Imaging.ImageFormat.Jpeg)
    
    0 讨论(0)
  • 2021-01-03 03:11

    Capture the active-form.

    Private Sub tsbCamera_Click(sender As Object, e As EventArgs) Handles tsbCamera.Click
        Dim bm As New Bitmap(Width, Height)
        DrawToBitmap(bm, New Rectangle(0, 0, Width, Height))
        Dim name As String = InputBox("Name it:")
        bm.Save(Application.StartupPath & "\ScreenShot\" & name & ".png", System.Drawing.Imaging.ImageFormat.Png)
    End Sub
    
    0 讨论(0)
提交回复
热议问题