Use code to capture application screen

I need to run some code to capture a window of an application running on a Windows desktop (Windows XP is fine here).

There are several examples of VB6 on the Internet, but they tend to only capture a VB6 application or desktop. I am looking for a solution that captures a given window / application. So, I want to be able to specify the name of the app window to capture.

A quick search of Bing led to some code examples, but they captured the desktop or the current VB6 application. I want to change one of them to capture this window (named application).

However, before I do this, maybe someone has a link to sample vb6 or VBA library code that will capture / save the given named application window for BMP or some type of image file on the hard drive.

The link to the VB6 or VBA solution here is just fine. I am ready to modify an existing example.

+4
source share
2 answers

You probably already know this, but windows are identified by a unique 4-byte long called a window handle . Any sample of code for capturing the screen can be made by any window: desktop, current application or any running application. You just need to use the right window handle.

Here are some building blocks:

  • Find the window handle for the application based on the title or part of the label. Taken from Karl E Peterson excellent site VB6. Or here's a Microsoft KnowledgeBase article to do the same. EDIT Or for a one-time job like yours, just find it manually by clicking on the window with a debugging tool like Spy ++ or a free clone .
  • This is where the code captures the desktop screen , from Steve McMahon the excellent vbAccelerator. Just change the code so that it uses the window handle found in step 1, and not the window handle returned by GetDesktopWindow() .
+9
source

I collected some code here to fix the error from Access in another application, it uses windows for this as an exercise, so the code may come in handy for you: http://forum.lessthandot.com/viewtopic.php?f=95&t=7969# p39648

+1
source

All Articles