Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2006, 09:08 PM
Authorized User
 
Join Date: Sep 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Screen capture issue

Hello,

I'm trying to write my own "screen magnifier" program on behalf of my mom. Her vision is quite poor and we intend to use this software to help her on a dual monitor system.

I can capture the screen image easy enough using the

  System.Drawing.Graphics.CopyFromScreen()

instance method. The problem is that this method doesn't capture
various tool tips. For instance, some tool tips it doesn't capture are:

  - Any tool tip popping up while hovering the mouse over
    the "quick launch" toolbar.

  - Any tool tip popping up while hovering the mouse over
    text in the VisualStudio property window.

I imagine that the method fails to copy other images actually being displayed on the screen.

Does anyone know how to obtain these elusive images? Thank you in advance.

- Roger
__________________
Cheers.

- Roger Nedel
 
Old September 22nd, 2006, 03:35 AM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried the scenario , in my case it is pasting tool tips also.
Used the following method
 Graphics.CopyFromScreen (Int32, Int32, Int32, Int32, Size)
My Screen resoultion 1024 X 768.
Size c = new Size(Point(100,100));
g.CopyFromScreen (1024, 768, 100, 100, c); where g is Drawing Space.
I got the tool tip at the location 100,100 and it is painting in the Drawing space.



 
Old September 22nd, 2006, 11:28 AM
Authorized User
 
Join Date: Sep 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Venkataramana,

Thank you for your reply. I am going to experiment with your suggestion.

One question pops into my head at the outset...how did you know the location of whatever tooltip might have popped up? You use the example location of Point(100, 100), and you use the size of Size(100, 100), but the tool tip could conceivably be anywhere.

Did you enumerate desktop windows or child windows in some way to determine which tool tip (and it's associated screen rectangle) was being displayed? Thanks again.

- Roger
 
Old September 22nd, 2006, 01:51 PM
Authorized User
 
Join Date: Sep 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have decided to explore an alternate method for obtaining a screen capture that includes all tool tips. Note that some tool tips seem to appear (for instance, some Visual Studio tooltips are captured, while others - notably those in the property window - aren't). The important ones that fail to capture are any along the task bar, quick launch bar, system tray - in short, anything adjacent to the start menu's "start" button.

So I decided to test hitting the "Print Screen" button on my keyboard and pasting the contents of the clipboard into a word document. Sure enough, the screen capture resulting from this operation did include all tool tips.

The strategy then would be to:

1. Run a timer control.
2. Each tick, try to force Window's to perform it's "Print Screen" operation, copying the screen to the clipboard.
3. Use the Clipboard.GetImage() method to retrieve the newly captured screen image.

One problem, however. I can't seem to force Windows to capture the screen via code. It only works when I physically press the "Print Screen" key.

I've deleted my test code, but it looked something like:

Code:
    private void Timer_Tick(object sender, EventArgs e)
    {
      // Since Graphics.CopyFromScreen() doesn't copy all tooltips,
      // try to force Windows to copy the screen (including tooltips)
      // to the clipboard.  Do this by simulating a "Print Screen" 
      // button key up command.

      this.OnKeyUp(new KeyEventArgs(Keys.PrintScreen));
    }

    protected override void OnKeyUp(KeyEventArgs e)
    {
      // Allow the base object to handle the key press in order
      // to force Windows to capture the screen to the clipboard.

      base.OnKeyUp(e);

      if (Clipboard.ContainsImage())
      {
        // Retrieve the newly captured desktop image.
        Image desktopImage = Clipboard.GetImage();

        // Using the image, update my magnification display.
        this.UpdateMagnifier(desktopImage);
      }
    }


Any ideas on how to simulate a "Print Screen" buttn keypress in order to force Windows to copy the screen to the clipboard. Thanks.

- Roger





Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Screen Capture sujeetji Pro PHP 2 December 1st, 2006 06:47 AM
Draw on the screen without clearing the screen pu132 Visual Basic 2005 Basics 0 August 25th, 2006 09:03 PM
screen scraper issue chiu08820 C# 2005 0 March 20th, 2006 09:32 AM
Capture Screen and Paste to Word Document SerranoG Access VBA 0 June 9th, 2005 03:49 PM
Hide controls/GUI components before screen capture wmoy VB.NET 0 January 10th, 2005 05:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.