Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB7
Expertise: Intermediate
Dec 1, 2003

GetScreenSnapshot - Retrieving the current contents of the screen or the active window

' Return the current contents of the screen or the active window
' It works by simulating the typing of the Print-Screen key (and Alt key if 
' activeWindowOnly is True), which dumps the screen to the clipboard.
' 
' Example: PictureBox1.Image = GetScreenSnapshot(True)

Function GetScreenSnapshot() As Image
    Return GetScreenSnapshot(False)
End Function

Function GetScreenSnapshot(ByVal activeWindowOnly As Boolean) As Image
    ' Alt-Print Screen captures the active window only
    If activeWindowOnly Then
        SendKeys.SendWait("%{PRTSC}")
    Else
        SendKeys.SendWait("{PRTSC 2}")
    End If

    ' return the bitmap now in the clipboard
    Return DirectCast(Clipboard.GetDataObject().GetData(DataFormats.Bitmap), _
        Image)
End Function
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap