Solved

VB5 Screen capture

Posted on 1997-10-23
6
310 Views
Last Modified: 2008-03-06
How can I capture the screen?
0
Comment
Question by:Evil
6 Comments
 
LVL 6

Expert Comment

by:alamo
Comment Utility
There are are a couple of ways. First of all though, I know of no way to do it tightly integrated into a VB program via API or commercially available control, and this would obviously be the best. new ones pop up all the time though, and if anyone reading this knows of such a beast post a comment and I'll defer.

But this is what I know: If you need simple occasional user-initiated full screen capture you can't beat for simplicity having the user press Shift+PrintScreen to capture the screen to the clipboard. Then in your code use:
Picture1.Picture = Clipboard.GetData(2)
and you now have the screen image.

For some applications that is enough; if it's not I suggest you call an external screen capture program. The one I use is called  HyperSnap... it's very flexible. You can have it snap the whole screen or just a section, it will even scroll windows to capture the portion that's not visible. You can call it with command line arguments or run it and use SendKeys to send it commands. It will save to clipboard or to file, autoincrementing the filename for successive timed captures. You can find it at http://www.hyperionics.com/. I have no relationship with the company other than that of satisfied customer.
0
 

Author Comment

by:Evil
Comment Utility
I'd rather not use an external program.

Are there any components out there that can capture the screen automatically?
0
 
LVL 3

Expert Comment

by:ChrisLewis
Comment Utility
What are you trying to do???  Is your capture based off of a keystroke, or a timer or a button?

Probably the simpliest way is as alamo stated:
After pressing PrintScreen,
Picture1.picture = Clipbard.Getata(2)

This is pretty standard windows functionality.

chris
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 5

Expert Comment

by:dirtdart
Comment Utility
You can also do a BitBlt to copy whatever section of the screen you want.  The two decarations you need are:

Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

hDestDC should be the hDC of the form you want to send to.  x, y, nWidth, nHeight are the upper left corner coordinates and the width and height of the area you want to send to.   hSrcDC is the source destination.  In this case, since it is the screen, you can pass a null value to GetDC to return the hDC of the screen.  xSrc, and ySrc are the upper left corner coordinates of the area you want to capture.  dwRop is a long value that should be set to &HCC0020 for this.

0
 

Author Comment

by:Evil
Comment Utility
how do i set that to null?
0
 
LVL 5

Accepted Solution

by:
dirtdart earned 50 total points
Comment Utility
Dim x as long
x = GetDC()

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

10 Experts available now in Live!

Get 1:1 Help Now