Results 1 to 4 of 4

Thread: Screenshot

  1. #1
    Guest

    Arrow

    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.

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    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

  3. #3
    Guest
    SavePicture Picture1, App.Path & "\MyPics.bmp"

    "Wrong number of arguments or invalid property assignment"

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Smile

    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.

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width