Is there a way I can take a screenshot of the screen and save it to a file. If there is any way to set the quality and color (color & B&W) properties please tell me how to set those too.
Printable View
Is there a way I can take a screenshot of the screen and save it to a file. If there is any way to set the quality and color (color & B&W) properties please tell me how to set those too.
Try this.
Code:Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Private Sub Command1_Click()
'Capture the Entire Screen
keybd_event VK_SNAPSHOT, 1, 0, 0
'Save the capture image
SavePicture
End Sub
Private Sub Command2_Click()
'Capture the Active Window
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
'Save the capture image
SavePicture
End Sub
Private Sub SavePicture()
'Delay 3 seconds
Sleep 3000
'Load Image into the PictureBox
Picture1.Picture = Clipboard.GetData()
'Delay 3 second to complete load the image into the PictureBox Control
Sleep 3000
'Save new image file
SavePicture Picture1, App.Path & "\MyPics.bmp"
End Sub
SavePicture Picture1, App.Path & "\MyPics.bmp"
"Wrong number of arguments or invalid property assignment"
Hi! conquerdude, Sorry abt the sample code. The SavePicture
function should be use others name. "coz it crash with the
VB global object "SavePicture" and that the reason why you
encounter error.
Here the correct one.
Cheers!Code:Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Private Sub Command1_Click()
'Capture the Entire Screen
keybd_event VK_SNAPSHOT, 1, 0, 0
'Save the capture image
Save2File
End Sub
Private Sub Command2_Click()
'Capture the Active Window
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
'Save the capture image
Save2File
End Sub
Private Sub Save2File()
'Delay 3 seconds
Sleep 3000
'Load Image into the PictureBox
Picture1.Picture = Clipboard.GetData()
'Delay 3 second to complete load the image into the PictureBox Control
Sleep 3000
'Save new image file
SavePicture Picture1, App.Path & "\MyPics.bmp"
End Sub