Results 1 to 28 of 28

Thread: VB.NET - Screenshot to jpeg...

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460

    VB.NET - Screenshot to jpeg...

    Im shure this will do the trick for many people.
    VB Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
    2.     Private Const VK_SNAPSHOT As Short = &H2Cs
    3.    
    4.    
    5.     Public Function SaveScreen(ByVal theFile As String) As Boolean
    6.         Dim data As IDataObject
    7.         data = Clipboard.GetDataObject()
    8.         Dim bmap As Bitmap
    9.         If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
    10.             bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
    11.             Me.PictureBox1.Image = bmap
    12.             Me.PictureBox1.Image.Save(theFile, Imaging.ImageFormat.Jpeg)
    13.         End If
    14.     End Function
    15.  
    16.     Private Sub Command2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command2.Click
    17.         Call keybd_event(System.Windows.Forms.Keys.Snapshot, 0, 0, 0)
    18.         System.Threading.Thread.Sleep(200) ' To have time to catch the clipboard
    19.         SaveScreen("c:\test.jpg")
    20.     End Sub
    Last edited by Libero; Apr 26th, 2004 at 10:13 AM.

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