Results 1 to 6 of 6

Thread: screenshot taker help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    3

    screenshot taker help

    have this code i found

    Code:
    Dim ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
    Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
    Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)
    g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
    screenGrab.Save("C:\" & Label1.Text & ".jpeg")
    Put i get this error on the screenGrab.Save part

    Code:
    A generic error occurred in GDI+.
    Any hellp or can someone give me different code that works. I want the screenshot to take and save upon mouse click

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: screenshot taker help

    Which line causes an error? Check what's in your Label1.Text. I think that the filename you try to save the screen to has illegal characters or empty. I checked with this:

    vb Code:
    1. screenGrab.Save("C:\test.jpeg")

    and it worked as charm.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    3

    Re: screenshot taker help

    nope still get the same issue wit screengrab.save problem

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: screenshot taker help

    I can confirm this works for me as well, even with 2 monitors.

    Code:
            Dim ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
                    Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
                    Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)
                    g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
                    screenGrab.Save("C:\file.jpeg")

  5. #5
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: screenshot taker help

    Quote Originally Posted by xx_lol_xx View Post
    nope still get the same issue wit screengrab.save problem
    My guess is you don't have permission to write to the folder on "C:\", in Win7 I usually use one of the public folders to save images when testing code.

    Also it is a good idea to set the image format in the .Save call, in VB10/WinXP just calling screenGrab.Save("c:\file.jpeg") actually saved the image as a PNG type on my system.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    3

    Re: screenshot taker help

    Your right edgemeal, although i found it out for myself it was the problem. I didnt have permission. Which is strange because I haven't had windows 7 long but on xp it allows me to create files in their.

    Thanks for your help.

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