Visual Basic > Code Snippets
Screen capture
Screen capture 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 CaptureScreen(ByVal myFile As String) As Boolean On Error GoTo ErrorHandler 'Check if the file Exists If Dir(myFile) <> "" Then Exit Function 'capture the complete screen Call keybd_event(vbKeySnapshot, 1, 0, 0) 'To get the Active Window 'Call keybd_event(vbKeySnapshot, 0, 0, 0) SavePicture Clipboard.GetData(vbCFBitmap), myFile CaptureScreen = True Exit Function ErrorHandler: MsgBox "Error Occured " & Err.Description End Function Private Sub Command1_Click() Call CaptureScreen("c:\screencap.bmp") End Sub
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows