Thread: Window capture

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    6

    Smile Window capture

    Hello Everyone

    I am writing an application that captures a window. My application needs also to work when the desktop is locked. When I am trying to capture an MFC window it works fine. However when I try to capture a C# window (when the desktop is locked), the C# window controls (such as buttons, text box and etc.) are captured as black rectangles.
    Why is it happening ? I understand there is some difference between MFC and C# controls probably...
    Is there a way to overcome this problem ?

    Thanks,
    Tal

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    What sort of application is this?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    6
    Hi

    What do you mean?
    It's a C# application using C++ DLL. The C# application does alot of things, among them capturing an image of a form. The form image is being captured using C++ DLL

    Is that what you mean ?

    Thanks for your reply
    Tal

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I think Salem is saying this app sounds like it is malicious (spyware).

    We don't help with apps that sound like they are intended to do something I would not like done to my computer or data.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    6
    Ahhhh...

    I was convicted before even trialed... Isn't it suppose to be innocent until proven otherwise ?
    How did you guys come to that conclusion ?
    Why would a spyware capture a window ? Why not to copy to whole desktop window ?

    Anyway, this is not a spyware application (and god is my witness).
    This is a part of a startup project (I don't know if I can say more now). The user has to start the application and he should be able to use it when he is away and that is why I want to capture the window when the desktop is locked.

    I would appreciate the help.

    Thanks, Tal

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Quote Originally Posted by tallubko View Post
    Why would a spyware capture a window ? Why not to copy to whole desktop window ?
    To wait until a login window appears so you can work out which keystrokes are the user/pwd?
    To send the smallest amount possible across a network?
    Because it is better to target the app you want to spy on, rather than monitoring everything that is happening on the PC?
    And many other reasons....

    Quote Originally Posted by tallubko View Post
    Anyway, this is not a spyware application (and god is my witness).
    As a athiest I object to your flagrant disregard for my beliefs.......

    Quote Originally Posted by tallubko View Post
    This is a part of a startup project (I don't know if I can say more now). The user has to start the application and he should be able to use it when he is away and that is why I want to capture the window when the desktop is locked.
    How can a user interact with an application while they are away from the PC?
    How can a user interact with an application while the PC is locked?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    Registered User
    Join Date
    Nov 2007
    Posts
    6
    Hi novacain

    When you phrase it like that it does sound malicious...
    But all I wanted to know was how the capture the window image and not to:
    1) Get the keystrokes when the login window appears
    2) To know how to send across the network

    How can a user interact with an application while they are away from the PC?
    The user can connect remotely the his PC, to a specific application, and that is why I need to capture the window. How do you ask ? aren't there applications that do that already (remote desktop, VNC and more...)

    How can a user interact with an application while the PC is locked?
    The user gets the window image and can interact with the desktop even if it locked. I don't want the user to login when he is away...

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    There is a problem with this whole concept:
    When you are "copying" the window content, you are using the GDI part of Windows, which gives you exactly what is shown on the display device at the time - which means that if the PC is locked, all you will EVER get is the locked PC dialog, background and/or screensaver scenery. You will not be able to "see" what any application is doing by this method.

    I know this, becuase I've been writing display drivers.

    You may be able to solve your entire problem using the machine in "Remote Desktop" mode, tho'.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Nov 2007
    Posts
    6
    Hi matsp

    I have succeeded capturing MFC window using GFI even when the pc was locked (by activating switch user option - I can add the code for that if you'd like).
    My problem was capturing C# windows when the desktop was locked. My application captured the form window but not the controls inside it...

    Thanks for your reply
    Tal

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Ok, so if you have fast user switching on, then, if you switch to another user, the PC is no long locked, agreed?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I wonder if it would possible to redirect the window painting to another context which is not used for showing up on the screen, but only for recording? So the destination application will draw it using the context handle controlled by the local application. This way it would work anyway, even if the user is switched, PC is locked etc.

    Though I don't find any practical use to this, it is an interesting idea.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    And probably bork rendering on its own window since it renders to another context. But it should be possible to blit the context onto the owned application window whose context it's stealing, I think.

  13. #13
    Registered User
    Join Date
    Nov 2007
    Posts
    6
    So Here is what I've found so far

    1) It isn't possible to capture hidden window using GDI (hidden means, behind other window or out of desktop "seen" area). It isn't possible to capture minimized window using GDI.

    2) It is possible to capture hidden window using PrintWindow (hidden means, behind other window or out of desktop "seen" area). It isn't possible to capture minimized window using PrintWindow.

    3) When desktop is locked, It isn't possible to capture a window using GDI, but it is possible to capture it using PrintWindow. I have a problem capturing C# controls when desktop is locked but MFC windows are captured OK.

    4) The methods I've found that capture minimized windows involve restoring it first !!!
    However there is a trick doing it described in
    http://www.codeproject.com/useritems...izedWindow.asp

    5) All the above doesn't include capturing windows drown by DirectX - I haven't checked it !!!

    6) I haven't checked capturing with DirectX.

    Tal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  4. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM