Visual Basic Screen Capture, with know coordinates.

Posted on 2011-05-01
Last Modified: 2012-05-11

 I am wondering if I can supply a manual set of coordinates of the X / Y location to capture from. Using this currently and works great for the whole screen, but want to supply the location of where to capture from manual coords that I can plug in. Thanks

Dim bounds As Rectangle
        Dim screenshot As System.Drawing.Bitmap
        Dim graph As Graphics
        bounds = Screen.PrimaryScreen.Bounds
        screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
        graph = Graphics.FromImage(screenshot)
        graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
        Enhance_Performance.PictureBox1.Image = screenshot

Open in new window

Question by:Jack_Jones
    LVL 17

    Accepted Solution

    Hi, the answer to your question is in your code, just change this line:
    bounds = Screen.PrimaryScreen.Bounds

    Open in new window

    bounds = New Rectangle(X, Y, Width, Height)

    Open in new window

    Where X and Y are your coordinates, and Width and Height the area to copy, what else do you need?
    LVL 17

    Expert Comment

    by:Carlos Villegas
    Or maybe I'm over simplifying your question?...
    LVL 1

    Author Closing Comment

    It's dead on for the x, y, and does what I need it to. Thanks for the help. ;)
    LVL 17

    Expert Comment

    by:Carlos Villegas
    Glad to help buddy!

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now