Search Tools Links Login

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.

Original Author: $mTp



Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Public Function Capture_Desktop(ByVal Destination$) as Boolean

On Error goto errl


Call keybd_event(vbKeySnapshot, 1, 0, 0) 'Get the screen and copy it to clipboard

DoEvents 'let computer catch up

SavePicture Clipboard.GetData(vbCFBitmap), Destination$ ' saves the clipboard data to a BMP file

Capture_Desktop = True

Exit Function


Msgbox "Error number: " & err.number & ". " & err.description

Capture_Desktop = False

End Function
'A lil' example

Private Sub Command1_Click()

Capture_Desktop "c:windowsdesktopdesktop.bmp" 'That's it

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 66 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.