PDA

Click to See Complete Forum and Search --> : print screen


nir_h20
Jan 11th, 2001, 02:23 AM
hello
how can I load the picture that is seen on the screen
to a picture.
i can't find the API that preforms that.
thnx

Chris
Jan 11th, 2001, 03:23 AM
nir_h20, try the following sample 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


Cheers!