CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2008
    Posts
    5

    screengrap of desktop

    Hi

    I use a java applet which displays live stockmarket information, and I want to be able to analyse those prices in a C++ program.

    Rather than trying to decompile that applet I think that an easier solution will be to make screen grabs of the desktop and perform a really simple optical character recognition on the resulting bitmap.

    My problem is that I do not know how to perform the screen grabs. After some googling it seems that I need to use the function GetDesktopWindow() and the data type HBITMAP, but I'm non the wiser on how to put this together. If I do manage to make a succsessful screen grap to a HBITMAP I will then need to know how HBITMAP stores the image so that I can access the pixels and perform my OCR.

    If it is possible I just want to write a consol application as this is all I'm familiar with, I have virtually no experience with visual programs.

    Thanks in advance for your help

    Paul

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: screengrap of desktop

    On Windows XP and later OS, you can use PrintWindow().

    For previous operating systems you have to get the desktop window handle, get it's device context, create a compatible DC, create a compatible bitmap, copy from the original DC to the memory DC.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Dec 2008
    Posts
    5

    Re: screengrap of desktop

    I'm using XP, so I guess PrintWindow() would fit the bill

    Few of questions
    1) What headers do I need to include to use it?
    2) Can it be used from a nonvisual / console application
    3) What data type does it return or take as arguments

    If you have a reference to an example where it is used, that would be great.

    Cheers

  4. #4
    Join Date
    Jan 2008
    Posts
    178

    Re: screengrap of desktop

    Can't you read MSDN ?!

  5. #5
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: screengrap of desktop

    I think that an easier solution will be to make screen grabs of the desktop and perform a really simple optical character recognition
    I think it's much easier to locate the window that contains the applet and copy it's text.

  6. #6
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: screengrap of desktop

    Quote Originally Posted by pernest View Post
    I'm using XP, so I guess PrintWindow() would fit the bill

    Few of questions
    1) What headers do I need to include to use it?
    2) Can it be used from a nonvisual / console application
    3) What data type does it return or take as arguments

    If you have a reference to an example where it is used, that would be great.

    Cheers
    MSND? http://msdn.microsoft.com/en-us/library/ms535695.aspx
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  7. #7
    Join Date
    May 2005
    Posts
    4,954

    Re: screengrap of desktop

    Quote Originally Posted by pernest View Post
    Hi

    I use a java applet which displays live stockmarket information, and I want to be able to analyse those prices in a C++ program.

    Rather than trying to decompile that applet I think that an easier solution will be to make screen grabs of the desktop and perform a really simple optical character recognition on the resulting bitmap.

    My problem is that I do not know how to perform the screen grabs. After some googling it seems that I need to use the function GetDesktopWindow() and the data type HBITMAP, but I'm non the wiser on how to put this together. If I do manage to make a succsessful screen grap to a HBITMAP I will then need to know how HBITMAP stores the image so that I can access the pixels and perform my OCR.

    If it is possible I just want to write a consol application as this is all I'm familiar with, I have virtually no experience with visual programs.

    Thanks in advance for your help

    Paul


    This article might help.
    Before using OCR did you try Microsoft Accessibly? You can check with AccExploer.exe to see if it sees the text.

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured