Results 1 to 7 of 7

Thread: Screen Picture of webrowser.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Posts
    297

    Screen Picture of webrowser.

    I was just wondering if it's even possible to take a screen capture of the webbrowser an save that picture as a jpeg.

    Thank you

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Screen Picture of webrowser.

    have a look at the screen capture link in my signature

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Posts
    297

    Re: Screen Picture of webrowser.

    Quote Originally Posted by .paul. View Post
    have a look at the screen capture link in my signature
    I cannot get it to work on vb.net 2010

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Screen Picture of webrowser.

    did you try this one?

    http://www.vbforums.com/showpost.php...7&postcount=14

    if it still doesn't work, tell me the error + i'll help you get it working

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Posts
    297

    Re: Screen Picture of webrowser.

    Quote Originally Posted by .paul. View Post
    did you try this one?

    http://www.vbforums.com/showpost.php...7&postcount=14

    if it still doesn't work, tell me the error + i'll help you get it working
    It works fine. but what button I press to take the picture? Its so confusing

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Screen Picture of webrowser.

    just press your prtscr button. (read the full thread)
    for choices about what to capture, doubleclick the icon in the system tray.
    if you just want to incorporate a screen capture into your app, the capturing is done in the clsScreenCapture.vb class

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Posts
    297

    Re: Screen Picture of webrowser.

    Quote Originally Posted by .paul. View Post
    just press your prtscr button. (read the full thread)
    for choices about what to capture, doubleclick the icon in the system tray.
    if you just want to incorporate a screen capture into your app, the capturing is done in the clsScreenCapture.vb class
    Ok im using this

    vb.net Code:
    1. Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    2.  
    3.         Dim image As Bitmap
    4.         Dim fileName As String = ""
    5.         fileName = My.Application.Info.DirectoryPath & "\images\" & Replace(Now.ToString.Replace("/", "-"), ":", ".") & ".png"
    6.         image = CaptureWindow(User32.GetForegroundWindow, Nothing)
    7.         image.Save(fileName, Imaging.ImageFormat.Png)
    8.  
    9.     End Sub
    10.  
    11.     Public Function CaptureWindow(ByVal handle As IntPtr, ByVal r As Rectangle) As Image
    12.         ' get the size
    13.         Dim windowRect As New User32.RECT
    14.  
    15.         Dim width As Integer
    16.         Dim height As Integer
    17.  
    18.         If r = Nothing Then
    19.             User32.GetWindowRect(handle, windowRect)
    20.             'windowRect.left = SplitContainer2.Panel1.Left
    21.             'windowRect.top = SplitContainer2.Panel1.Left
    22.  
    23.             width = windowRect.right - windowRect.left
    24.             height = windowRect.bottom - windowRect.top
    25.         End If
    26.  
    27.         Dim img As Bitmap = New Bitmap(width, height)
    28.         Dim gr As Graphics = Graphics.FromImage(img)
    29.         gr.CopyFromScreen(windowRect.left, windowRect.top, 0, 0, New Size(width, height))
    30.  
    31.         Return img
    32.  
    33.     End Function
    34.     Public Class User32
    35.  
    36.         Public Structure RECT
    37.             Public left As Integer
    38.             Public top As Integer
    39.             Public right As Integer
    40.             Public bottom As Integer
    41.         End Structure 'RECT
    42.         Declare Function GetDesktopWindow Lib "user32.dll" () As IntPtr
    43.  
    44.         Declare Function GetWindowRect Lib "user32.dll" ( _
    45.             ByVal hwnd As IntPtr, _
    46.             ByRef lpRect As RECT) As Int32
    47.  
    48.         Declare Function GetForegroundWindow Lib "user32.dll" _
    49.         Alias "GetForegroundWindow" () As IntPtr
    50.  
    51.     End Class 'User32
    52. End Class

    but the problem is that it will take a screenshot of the current active window. How can I change that to take a screen shot of the application and not the curent active window?

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width