Advertisement
2002ASP Windows API Call/ Explanation #2522

Capture desktop/Screen shot, and save to file, easiest way using only one API call!! A must see!

This will take a screen shot using only one API call, no bitblt and other complicated routines. This is simple and works. This code will simulate a keypress (the snap shot button), then will copy the data to clipboard (like if you had pressed the Snap shot button on your keyboard) and save it to file. Vote for me or gimme' some feedback if you think this is cool.

AI

Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Zdrojový kód
original-source
'****Declares
<Font face="verdana" size ="2"><P>Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)</P>
<P>Public Function Capture_Desktop(ByVal Destination$) as Boolean </P>
On Error goto errl
<br>DoEvents
<br>Call keybd_event(vbKeySnapshot, 1, 0, 0) 'Get the screen and copy it to clipboard
<br>DoEvents 'let computer catch up
<br>SavePicture Clipboard.GetData(vbCFBitmap), Destination$ ' saves the clipboard data to a BMP file
<br>Capture_Desktop = True
<br>Exit Function
<br>errl:
<br>Msgbox "Error number: " & err.number & ". " & err.description
<br>Capture_Desktop = False
<br>End Function
'A lil' example 
<br>Private Sub Command1_Click()
<br>Capture_Desktop "c:\windows\desktop\desktop.bmp" 'That's it
Původní komentáře (3)
Obnoveno z Wayback Machine