|
|
Title | Use the Clipboard to grab an image of the screen in Visual Basic .NET |
Description | This example shows how to use the Clipboard to grab an image of the screen in Visual Basic .NET. |
Keywords | desktop image, background, clipboard, PrntScrn |
Categories | VB.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
|
|
|
|
|
|