Results 1 to 11 of 11

Thread: Saving a clipboard image to a file?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    89

    Saving a clipboard image to a file?

    Hello,

    I ran a few searches on the forum on how to do screenshots. That part is working fine, but how would you save the screenshot to the C:\ ??

    So far I have:

    VB Code:
    1. Form1.Picture1.Picture = Clipboard.GetData()
    2. SavePicture Clipboard.GetData, "C:\snap\six.jpg"

    Any suggestions?

    chris

  2. #2
    Hyperactive Member temp_12000's Avatar
    Join Date
    Jan 2004
    Location
    LA, USA
    Posts
    411

    Re: Saving a clipboard image to a file?

    Originally posted by Trancedified
    Hello,

    VB Code:
    1. Form1.Picture1.Picture = Clipboard.GetData()
    2. SavePicture Clipboard.GetData, "C:\snap\six.jpg"

    chris
    try:
    VB Code:
    1. Form1.Picture1.Picture = Clipboard.GetData(vbCFBitmap)
    2. Dim myPic As New StdPicture
    3. Set myPic = Clipboard.GetData(vbCFBitmap)
    4. SavePicture myPic, "C:\snap\six.jpg"



  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    89

    error

    Temp,

    Thanks for your reply but i get an error here:


    VB Code:
    1. SavePicture myPic, "C:\snap\six.jpg"

  4. #4
    Hyperactive Member temp_12000's Avatar
    Join Date
    Jan 2004
    Location
    LA, USA
    Posts
    411

    Re: error

    Originally posted by Trancedified
    Temp,

    Thanks for your reply but i get an error here:


    VB Code:
    1. SavePicture myPic, "C:\snap\six.jpg"
    You need save it as BMP:
    SavePicture myPic, "C:\snap\six.bmp"

    to save it as JPG, you need do some extra work.



  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    89

    Unhappy Same error

    Temp,


    I tried it again w/ a bmp extension, but the same error comes up as the previous post. Here's my screenshot code and the sub that saves the .bmp is on the bottom.

    VB Code:
    1. Private Type OSVERSIONINFO
    2. dwOSVersionInfoSize As Long
    3. dwMajorVersion As Long
    4. dwMinorVersion As Long
    5. dwBuildNumber As Long
    6. dwPlatformId As Long
    7. szCSDVersion As String * 128
    8. End Type
    9.  
    10. Private Declare Sub Sleep Lib "kernel32" (ByVal sleepTime As Long)
    11. Private Const KEYEVENTF_KEYUP = &H2
    12. Private Const VK_SNAPSHOT = &H2C
    13. Private Const VK_MENU = &H12
    14.  
    15. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    16.  
    17. Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
    18. Dim blnAboveVer4 As Boolean
    19.  
    20. Private Function SnapShot()
    21.  
    22.     If blnAboveVer4 Then
    23.         keybd_event VK_SNAPSHOT, 1, 0, 0
    24.     Else
    25.         keybd_event VK_MENU, 0, 0, 0
    26.         keybd_event VK_SNAPSHOT, 0, 0, 0
    27.         keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
    28.         keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
    29.     End If
    30.        
    31. End Function
    32.  
    33. Private Sub cmdSave_Click()
    34.     Form1.Picture1.Picture = Clipboard.GetData(vbCFBitmap)
    35.     Dim myPic As New StdPicture
    36.     Set myPic = Clipboard.GetData(vbCFBitmap)
    37.     [B]SavePicture myPic, "C:\snap\six.bmp"[/B]
    38. End Sub

    Any other ideas?

    Thanks,


    Chris

  6. #6
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    if that is your whole program, then you forgot to call

    SnapShot


    you are also going to need a little pause between screenshot taking and file saving or else you would get an error sometimes.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    If you want to save it as a JPG, look here...

    http://www.vbforums.com/showthread.p...hreadid=274353


    BTW our Good Old Platipus just uploaded his new PNG controll. Look for the thread in the game section. So if you want PNG picture you can probably use his controll. Havn't tested it yet tho'


    ØØ

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    89
    Buggy,

    Here's the remainder of the my code and I added the call to SnapShot. I still get the same error on the text that's bold.

    "invalid property value"


    VB Code:
    1. Private Sub cmdSixShow_Click()
    2.     Call Disable
    3.     Me.Timer1.Enabled = True
    4.     Picture13.Picture = Clipboard.GetData(vbCFBitmap)
    5.     Dim myPic As New StdPicture
    6.     Set myPic = Clipboard.GetData(vbCFBitmap)
    7.     [B]SavePicture myPic, "C:\snap\six.bmp"[/B]
    8.    
    9. End Sub
    10.  
    11. Public Sub Timer1_Timer()
    12.     timer1.interval = 100
    13.     Timer1.Enabled = False
    14.     cboSelection.Visible = False
    15.     Call SnapShot
    16.     Call Enable
    17. End Sub



    Any other suggestions?

  9. #9
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    try

    SavePicture picture13.picture, "C:\snap\six.bmp"
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    89
    Yeah same error "Invalid Property Value"

    Any other ideas? keep 'em coming!


    Chris

  11. #11
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Do you have a picturebox called Picture13 on your form. Becuase that cod eshould work. And you also have to have the path C:\snap\, might also consider turning the autoredraw property to true..

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