Conditionally hiding specific window from desktop screenshot - c#

Is this possible. I have three (3) windows:
Window1 - not active
Window2 - not active
Window3 - active
If I take the screenshot of the desktop I want Window3 to be hidden quietly. Provided the user is using Window3 the program must not in any way hide the windows like minimizing it or anything. In short, I need an unobtrusive way of hiding specific windows from desktop screenshot.

That's not going to be possible without quite a bit of work. The print screen functionality just copies the contents of the desktop DC to an image and places it on the keyboard. It doesn't actually re-render the whole desktop into a new DC. So there's no way that it can silently remove a particular window.
I suppose you could hook the print screen button (or the function, whatever it is) and allow it to create the image on the clipboard. Then your hook could read the location of the window in question from the desktop and clear out that area of the bitmap that's on the clipboard.
Your hook would do this:
call the normal print screen function
load image from clipboard
get location and size of Window3 from desktop
fill that rectangle in the image with black (or whatever)
put the modified image back on the clipboard
Assuming, of course, that you can hook the print screen function. I suspect it's possible, although I've never tried it.

Related

Draw rectangular selection and get corresponding image in WPF c#

I need to write a text recognition (from image) application. The main idea is that while my application is running, I may have the need to transform some text of an image into manageble text. So, in this case with the mouse I need to draw a square around the area that i need to capture and the software must convert the content of the extracted picture into text.
I solved the problem of image recognition. I also find a very easy way to capture from screen.
What I need to do now is be able to select with the mouse the interesting area that is over an other running opplication (for example over a webpage or over an image opened in Paint). That must be like the screencapture on windows7, you create a selection of the screen and this is saved like a picture.
By looking around, I didn't find anything and I don't knwo where to start.
Many thanks
You can achieve that using either a 'tricky' easy way or a real but difficult approach.
The tricky way
Screen Recorder applications usually use this approach:
Whenever user wants to select an area, you display a full screen border less Window with 0% opacity, then user attempts to select the screen area, and he is actually selecting your Window area, so you can receive mouse events and display/draw a rectangular shape to show the selection area to the user.
In this approach, the program needs to know when to display the Window and when to hide it. This can be done by for example defining Hotkeys for capturing:
Program registers a hot key using RegisterHotKey to Windows.
User presses and holds that hot key
Program displays the tricky Window
User selects the interested area, program receives that area using mouse events of the tricky Window
User released the hot key and program hides the Tricky window.
The real way
Using this way, you need to set a message hook in order to receive mouse and keyboard events while user is interacting with desktop not your program. This is not an easy to accomplish approach and I recommend you the first one.

C# Desktop App Bar (Somewhat Like a taskbar)

I've been googling a lot for this one and I can't seem to find anything. Maybe it's the way that I'm wording it. So basically what I'm looking to do in C# using Windows Forms, is create a form and have it essentially take the shape of the taskbar and do the same functions as the taskbar, but it will sit above the task bar or at the top of the screen.
It can't be "ON TOP" (I'm not trying to block user buttons like the close button of a program they are using).
Autohide would be a plus.
This is the main thing I'm after:
It needs to act just like the task bar. When you maximize any other window, the taskbar does not go over the top of the window, even though it is set to "on top".
You'll want to use an Appbar to do this:
http://msdn.microsoft.com/en-us/library/cc144177.aspx
For more information, check out here and here and here.
If you don't want to deal with C++ and Native Code (as #FKunecke correctly proposed) then you'll not find anything predefined for this. What you can do is create a form for your bar and make the visualization calculations by hand, then you can set the screen location of it. That's all. Not forcing the bar form to stay on top will not hide the other app forms so you'll get that for free.
Now, to fully implement what you want there are some problems you need to deal with, such as Taskbar location and height. Then you'll need to use some native code tricks.

Get Image painted on Window

I have a windows form Window that is being painted on top of by another process. If I try to copy the window image using PrintWindow or device context copy, only my window below shows up:
Window before it's painted on by another process:
Window after it's painted:
Window I get when I do PrintWindow or BitBlt:
Is it possible to read the window draw from the window directly without sending it the paint argument? Can I read it from the graphics card directly?
DirectX breaks the rules, you cannot make PrintWindow() work. Using Graphics.CopyFromScreen() doesn't work either, it has a critical bug that prevents you from passing the correct CopyPixelOperation value. One that was addressed in Windows 8 by Windows itself, you can't rely on it yet.
You'll need to fallback to BitBlt(). The critical option is CopyPixelOperation.CaptureBlt so that video overlays are included in the copy. You'll find the required code in this answer.
If I am correct you want to copy window that is rendered by some DirectX proccess?
You can do that but you need to understand that you can't copy memory from window directly because winows form doesn't have your image, it only have a placeholder for rendered image.
It is only a ilusion that image is rendered inside form.
What you need to do is to copy memory from graphic card but unfortunately I don't know how to do that.
Most simple idea is to get window screenshot like alt+print screen, remove the border and copy that image to your window.
Maybe it will help http://www.codeproject.com/Articles/274461/Very-fast-screen-capture-using-DirectX-in-Csharp
Dmitry is right.
You can only make a CopyFromScreen as he suggested:
Capture the Screen into a Bitmap
You can modify the source code to create a bitmap large as your window and copy only that part of screen

App that is not showing on projector

Is there a way to create an app on .NET that will be used when connected with projector/external PC but will be shown only on main screen?
Thanks.
I don't think this is possible. Powerpoint has the functionality of showing notes just on the primary display. But this is only possible when the desktop gets extended and not mirrored to the beamer.
So you shold have to extend the desktop to the beamer and then place the App window on the main screen manually.
System.Windows.Forms.Screen.AllScreens gives you access to monitor information in C#. The PrimaryScreen Property tells you, which screen is the main Screen. You may move the window from one screen to another by respecting the screen widths.

Monitor window (Screen capture)

I'm working on a c# wpf app in which I want a grid or rectangle to show the contents of a window in my application. It should be like a monitor which constantly shows what happens in the other window (video is being played in in it).
Is there a good way to capture the screen or some other option?
Thanks
You can take a look at the VisualBrush class - that might be able to handle what you want. I don't know if it can handle cloning video but this example shows it copying a static part of the screen.

Categories

Resources