0

I have a program that will automatically take screenshots and save them to files (ideally, not too big in size).

The main problem is that the code I've found on the Internet (below) doesn't take a full screenshot for me. I'm looking to get a full-screen capture. Any recommendations on how to modify the code?

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)
PictureBox1.Image = screenshot
jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
  • What does it capture for you instead of the full screen? – Ry- Jun 13 '19 at 04:17
  • If you have two questions then post them separately. Each question thread should be fully self-contained. If you receive an answer to your first question, you should be able to accept that answer and that be the end of it, not have people continuing to provide answers to a completely separate question. I have edited your post to remove the second question. – jmcilhinney Jun 13 '19 at 04:53
  • Also, your second question is too vague/broad for SO anyway. – jmcilhinney Jun 13 '19 at 04:54
  • If your app is not DPIAware and your screen is scaled, you'll get a virtualized measure. – Jimi Jun 13 '19 at 05:20
  • Jimi: My screen is scaled up to 150% so I think your comment is leaning toward the culprit of why I'm not getting a full screenshot. Can you point me to a post (or comment here) on how I can make the app DPIAware so the code above will take an entire screenshot? – vbcoder_mike Jun 14 '19 at 14:55
  • [How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?](https://stackoverflow.com/a/13228495/7444103). Using just the `app.manifest`. The `app.config` file can also be use and it's recommended. See: [High DPI Desktop Application Development on Windows](https://learn.microsoft.com/en-us/windows/desktop/hidpi/high-dpi-desktop-application-development-on-windows). See also [my post here](https://stackoverflow.com/a/50276714/7444103), for a collection of System-dependent Win32 function which can determine the same effect. – Jimi Jun 15 '19 at 01:03
  • See also this documentation, it can be useful: [Setting the default DPI awareness for a process](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/mt846517(v=vs.85)). Btw, I wasn't notified of your comment. You should prefix a nickname with `@` to ensure that a notification is delivered to a SO user. – Jimi Jun 15 '19 at 01:06

0 Answers0