[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Capturing GUI Screen of Child

Posted on 2000-01-14
9
Medium Priority
?
237 Views
Last Modified: 2010-05-18
This is my current problem:
I have a service which starts console app's just fine (in the
background)
NOW, I want to add gui applications.
a) can i prevent a gui app to appear on the screen ?
b) can i capture the gui of the child and send it somewhere
where it can be assembled again (e.g via sockets)?
c) how can i interact with the hidden gui (send mouse clicks to it, etc)
where do i have to look at (msdn references, www pages ...)
thanks !
0
Comment
Question by:boyracer
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2353461
You might try positioning the window of the GUI app  off display (beyond the edges of the display).  Then you can get the image on the GUI app window by sending it WM_PRINT or WM_PRINTCLIENT messages.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2353465
To "interact" with the GUI window, you woudl just send in mouse mewssages (WM_LBUTTONDOWN etc.) and keyboard messages WM_CHAR etc.)
0
 
LVL 86

Expert Comment

by:jkr
ID: 2354150
>>can i prevent a gui app to appear on the screen ?

On NT: yes
Win9x: no

The 'SW_HIDE' flag passed in the STARTUPINFO struct used in the call to 'CreateProcess()' or 'ShellExecute()' may be ignored by the created process. On NT, you could start the application on an invisible desktop.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 2

Accepted Solution

by:
tonp earned 1000 total points
ID: 2357020
I'm assuming that you're talking about a Windows environment.

a) yes. Using the CreateProcess call you can specify that the window must not be shown (STARTF_USESHOWWINDOW).

b) yes. Hook all relevant GDI functions, and for each call determine if it's done in the context of the application you started. If so, send it over the network and don't call the actual GDI function.

c) Use keybd_event and mouse_event.

Obviously, the tricky part is the capturing of the gdi calls. In your case it's perhaps an option to implement your own GDI32.dll, cantaining wrappers for all GDI functions. Rename the original gdi32.dll and call the functions from this dll.

Ton
0
 
LVL 86

Expert Comment

by:jkr
ID: 2357123
>>Using the CreateProcess call you can specify that the
>>window must not be shown

That's incorrect. As I stated above, the started application can ignore this value.

>>Hook all relevant GDI functions, and for each call
>>determine if it's done in the context of the application
>>you started.

When you've chosen to hide a process and it does not ignore this flag, what GDI activities do you expect to take place? ;-)
0
 
LVL 2

Expert Comment

by:tonp
ID: 2357143
JKR is right. This entire part (hiding the window) can be skipped (instead, the window _must_ be showed, either directly at startup or by doing a ShowWindow later).
Because of the GDI stubs (that filter out all activity for this application) nothing will show up anyway.

Ton
0
 

Author Comment

by:boyracer
ID: 2357154
hm,
i do not want to hook functions.
jkr's proposal of an invisible desktop seems better
if i still can capture the gui.
FYI: i am trying to implement something like VNC,
however i only want a single application to be
viewn
0
 
LVL 2

Expert Comment

by:tonp
ID: 2357254

I _think_ that when the application is not visible (moved outside the desktop or placed in an invisible desktop) it will receive no screen updates and/or drawing actions will fail (that makes sense anyway). Therefore it will never draw itself and you can't do what you want.

When you don't want to hook GDI functions, a different approach is the following:
 
- monitor updates by setting keyboard, mouse and messages hooks (for example, when the hook detects that a WM_PAINT messages is sent to the application you know that an update will take place)
- grab the application screen (bitblt it into a bitmap) and send the graphical data over the network.

Ton

0
 
LVL 22

Expert Comment

by:nietod
ID: 2357300
>>  _think_ that when the application is not visible (moved
>> outside the desktop or placed in an invisible desktop) it
>> will receive no screen updates and/or drawing actions
>> will fail
No, only the OS will not draw it automatically (won't send it WM_PAINT messages).  Which is good, because you don't want it to!

Then you can obtain the program's current appearance using WM_PRINT.

>> when the hook detects that a WM_PAINT messages
>> is sent to the application you know that an update will
>> take place) - grab the application screen (bitblt it into
>> a bitmap) and send the graphical data over the network.
But the application must not be visible on the computer that is running it!  so the screen doesn't contain the image you want to send.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

612 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