Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse the Clipboard to grab an image of the screen in Visual Basic .NET
DescriptionThis example shows how to use the Clipboard to grab an image of the screen in Visual Basic .NET.
Keywordsdesktop image, background, clipboard, PrntScrn
CategoriesVB.NET, Windows
 
The GetDesktopImage function grabs the desktop image by using the keybd_event API function to generate VK_SNAPSHOT, which simulates pressing the PrntScrn key.
 
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As _
    Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, _
    ByVal dwExtraInfo As Integer)
Private Const VK_SNAPSHOT As Short = &H2CS

' Return the desktop image.
Private Function GetDesktopImage() As Image
    keybd_event(System.Windows.Forms.Keys.Snapshot, 0, 0, 0)
    System.Threading.Thread.Sleep(200)

    If Clipboard.ContainsImage() Then Return _
        Clipboard.GetImage()
    Return Nothing
End Function
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated