Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Capture Active window in vb.net

Posted on 2007-03-31
4
Medium Priority
?
655 Views
Last Modified: 2013-11-07
Does anyone have or has seen an example of how to find the current active window on a desktop, find its cordinates and then screen shot it in to a bmp?
0
Comment
Question by:pamsauto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18829580
There are two basic ways to go about it:

(1) Use the GetForegroundWindow() API to get a handle to the active window.  Use the GetWindowRect() API to get the screen coordinates.  Use the BitBlt() API to copy it to an image (more APIs involved there).

(2) Press Alt-PrtScr and copy the resulting Image from the ClipBoard.

Do you have a preference in method?...
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 18829603
Method (2) is simply...

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Clipboard.Clear()
        SendKeys.SendWait("%{PRTSC}")
        Dim data As IDataObject = Clipboard.GetDataObject()
        If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
            Dim bmp As Bitmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)

            ' do something with "bmp"...
            PictureBox1.Image = bmp
        End If
    End Sub
0
 

Author Comment

by:pamsauto
ID: 18829831
I need method #1.  With the API calls you gave me I found what I needed.  They were solutions you made for users already!    

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21504191.html


As always Idle Mind - Thanks for your help.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18830192
=)
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 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