I know it's possible to capture a screen of an application that is behind another application, but I can't seem to find anything on capturing the screen of a minimized application.
Anyone happen to know if this is possible? I don't want to get into things like maximizing and minimizing the application really quick.
As #ziplin said with newer version of windows it may be possible (via DWM apis). From c# you can use the Windows API codepack to access the new apis
I don't believe so, simply because i've noticed programs that try to preview a window that is minimized seem to draw a blank on occasion if the window is minimized. Although, some new versions of windows (vista and 7, I believe) do this very thing, but I'm not sure how easy it is to replicate (at all)
: http://www.stardock.com/products/objectdock/
You can't without restoring the window. When a window is minimized, the application is not in a state to render a UI for your application to capture.
If anyone still wants to no a workable solution I tried this one and worked well for me. It does a trick for minimized windows (because windows does not refresh them, on the taskbar the iconic picture shows the last image of the window before it was minimized). And Ziplin above mentioned that Objectdock can capture minimized windows, actually it does the same as Windows, it uses the last image captured before minimizing.
So here is the link: http://www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick
I've never tried it. This code claims looks reasonable, but has caveats about minimized windows. It is, if nothing else, a place to start.
As a last resort: why not capture window just before it gets minimized?
I know its too late, maybe it might help others.
I thought of a different approach, instead of minimizing, I moved my form outside my screen co-ordinates before capturing the screen and later respawned it.
Below is my code example:
//Move the form beyond the screen
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width + 10, Screen.PrimaryScreen.Bounds.Height + 10);
// Screenshot code here...
//Respawn the form to origin location
this.Location = currentPosition;
Related
I have a WPF application running on a Windows 8.1 tablet. the application is using the following method to show the virtual keyboard:
public static void OpenKeyboard()
{
ProcessStartInfo startInfo =
new ProcessStartInfo(#"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
{
WindowStyle = ProcessWindowStyle.Hidden
};
Process.Start(startInfo);
}
However, the size of the active window that the keyboard is displayed on top of doesn't change accordingly, meaning that if I have a ScrollViewer surrounding all the elements of my window it doesn't respond to the keyboard.
Is there any way to make my windows aware of the keyboard presence?
Update
Tried registering to the SizeChanged event of the window but it's not raised when the keyboard pops up.
Since TabTip.exe is a separate process it doesn't fire any events in your WPF application. Since win 8.1 tabtip does not automatically resize windows anymore. (there have been a lot of complaints about it)
There are a couple of ways you can do this manually. Firstly, Win8 apps have so called "LayoutAware" pages. Something similar can be done in WPF using the VisualStateManager.
This is rather complex and might not be the best solution, but I included it nevertheless (VisualStateManager solution here
Another way is to get the tabtip process from the list of active processes and calculate its width and height and use it to manually resize your screens.
Tabtip is if I remember correctly about 270 in height. You can also directly resize your screens as soon as the process appears. Something like this;
public void OpenKeyboard()
{
ProcessStartInfo startInfo =
new ProcessStartInfo(#"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
{
WindowStyle = ProcessWindowStyle.Hidden
};
Process.Start(startInfo);
//this = your window
this.Height -= 270;
}
There is another more clean way. It is a bit difficult and I haven't tried it myself yet. It is possible to grab the process and resize it where you want. You might be able to do it with the Windows API call 'findWindow()', but as far as I know that doesn't always work with tabtip, you might have to use P/Invoke.
To get you started I found some pretty great sources from which I wont steal credit by copying the code here; How to resize another application's window in C#
Changing another applications size and position using P/invoke (win32)
I hope you find this info useful. I know how you feel and have struggled with tabtip myself more often than id like.
Footnote; isn't it easier to just decrease your max window height and move it to the top of the screen when osk is called and put it back when its killed?
As far as I know this happens if the window is maximized or not resizable. Mke sure its state is not maximized before opening the keyboard.
In another answer I provided from my own research on working with tablets, the following S/O link might help you.
Tablet App, Auto Rotation and Taskbar Height Adjustments
I found a variety of things that were not cool, but did come up with some understanding points. Depending on the keyboard, does it actually overlay, or is it part of the anchored taskbar at the bottom of the window with other open tasks. If so, that will inherently change the window available dimensions, almost like a user changing from a lower to higher resolution (or hi/low). This actually changes the view port dimensions for the windows to be displayed. You can hook into
SystemEvents.UserPreferenceChanged and
SystemEvents.DisplaySettingsChanged
to detect and trigger whatever resizing considerations you need. There is also code on forcing your tablet to remain in a single orientation. I needed this because our tablet has a barcode scanner on it and it makes sense to always have the tablet with the scanner NOT pointing to the person, so we have it locked in a specific direction while the app is running.
And lastly, how do you KNOW you have entered (or exited) tablet mode. This shows how to hookup with ManagementEventWatcher to detect when registry entry changes interactively such as rotation, or undocking from a station and becoming free to use in tablet mode.
From your feedback, lets have you try this. From my version of TabTip (Surface Pro tablet), in the top-left is the keyboard settings. From that, if you click on it, it will open a dialog that allow for different keyboard styles from full width, abbreviated, split keyboard and even stylus for writing directly. Below that is an option to have your keyboard docked as the taskbar (left button I circled in red) vs floating window on top of others (I believe yours is running). Try setting your keyboard to a DOCKED state, then check the tablet mode and window environment settings getting changed. Worked for me.
So I have tried searching for the better part of a day for the answer to a simple question. I want my C# application to popup another winform on a timer and then close it after a delay. Simple enough, done and done. Now my issue is that I want it to actually be on top of other applications UNLESS they are full screen. By that I mean a true full screen application such as a game. I do not want to interfere with such an application since it should take priority over my application.
The issue is that I am using the 'OnTop' property on the popup form and, while it works perfectly for any other applications I have been testing it while playing a full screen game and the form, when it "Show()"s, takes the full screen application and drops it into windowed mode.
Is this the intended effect of the 'OnTop' property with full screen applications? If so is there a way that I can have my form popup on top of normal windowed windows and not interfere with full screen applications?
Any links, example, a kick in the general direction is great. The only hits that I come up with when searching for winforms involving full screen is people trying to get their application into full screen or having their application take focus away from another application.
Thanks on advance.
(I didn't post any code due to it just being a simple winform that is "formX:Show()" on a timer with the "onTop" property set)
(EDIT) So thanks to awilson53 for putting me on the right track I was able to find a method (albeit somewhat picky) to determine if an application is full screen. Seems kinda simple, and an "well duh", answer after all is said and done.
95% of the credit goes to the author of the article: http://www.richard-banks.org/2007/09/how-to-detect-if-another-application-is.html
~5% goes to awilson53 for getting me on the right track. :)
Check out this wrapper for the EnumWindows function. This will allow you to enumerate all open windows and determine their window state. You will want to check the EnumWindowItem.Maximized property, and if it is true set your OnTop property to false. If none of the EnumWindowItem's return Maximised you can set OnTop to true.
How can I print screen minimized windows? I believe it's possible, since Windows task-bar can create a preview of a window even if it is minimized.
This guy managed to do exactly what you are after: http://www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick
I know this question is really old, but it can still be valid for someone.
I'm pretty confident that this is not possible, at least by an external application like yours. When an application window is minimized, the window cannot (and does not) receive WM_PAINT messages, meaning that it is impossible to ask the window to redraw itself while it is minimized (or, "take a picture of it"). This is a limitation (or a rule) of the Windows API.
The taskbar "gets around this" by displaying a cached image (which is the last snapshot the DWM took of the window before it was minimized) and so it is not in fact taking a current picture of the window. You can test this by running an application which periodically updates itself, and then minimizing it -- you will see that the preview image will not be updated until it is restored.
The only way you could get around this is to do what the taskbar does -- periodically take a picture of the window you want, and when it is minimized, use the cached image instead. Of course, this means your app will have had to have been following the target window some time in advance (this obviously won't work if the first time you want to take a snapshot of the window is while it is minimized).
I wanted to create a program that would allow me to open instances of a already exsiting program (i just have the exe) as windows inside (i belive its called mdi)
Is that something i could do? can anyone point me to an example?
Thanks
Maybe this is the answer you are looking for here. It can be done...look in the sample on that link given.
Hope this helps,
Best regards,
Tom.
When Windows starts a program its parent is the Desktop Window.
If you could somehow manipulate that, it may work.
However, I doubt it is possible, as why would I want to allow you to run my application in your window? Especially MDI? Besides that - running in a child window isn't quite the same as running in the "main" window.
Having said that there is an application out there (can't think of it's name OH) that does place individual applications in tabs. Pretty nifty if you're not on Windows 7. The folks over at the Business of Software forum might be able to help you find it.
Well, after starting the app and storing its PID, you could start monitor the windows that get created, either thru a CBTHook or by just using a timer and the GetWindows to find when a top level window gets created by the PID in question.
Then you can use SetParent to make that window a child to your MDIChild (I doubt you can make it your MDIChild directly).
That should get you going. What you'll run into after that I really don't know. I guess you must correlate any movement of either your app or the external app so that thir windows appears to be stuck together...
Maybo you could strip away the caption from the external app (Get/SetWindowsLong). That could make it look better...
I have a fullscreen window, and I want to prevent pop up windows that appear at the right bottom corner of my screen. I set the Topmost property to true, but apparently it does not help. I also tried activating the form and giving it the focus once it got deactivated, but that did not help either. What is a way to ignore such windows while the user is engaged with the fullscreen app? I am .NET programming in C#.
You can't do it, this fails the "what if two programs tried to do this" test:
those popups are just normal windows like yours, they also use the same top-most style you are using.
if there was a way to always be above other topmost windows they would have used it too rendering it useless (because the authors of the other apps are just as concerned about the user missing their "super important" notifications as you are about them interfering with your full screen app).
You can try and play dirty tricks to force your window to the top of the top-most z-order, but those popups are likely to use the exact same tricks, again making this all useless (and as an extra bonus all those dirty tricks can turn your app into a compatibility nightmare).
You can disable these balloon notifications using these steps:
Click Start, Run and type regedit
Navigate to the following subkey:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
In the right pane, create a DWORD value named EnableBalloonTips
Double-click the new entry, and give it a value of 0.
Quit Registry Editor.
Log off Windows (this is not very cool...), and then log back on for the changes to take effect.
if you need help in how doing this by program, don't hesitate to ask ;)
I don't think that you can block all the popups, windows might not let you do that. But you can try with SetWindowPos function and pass it HWND_TOP parameter. It might work a little better than Topmost = true.
I used a sys tray popup control on my personal project SvnRadar written in WPF.
The control is at the http://www.hardcodet.net/projects/wpf-notifyicon written by Philipp Sumi.
Very nice.Only thing you will be need to "detach" it from the SysTray screen coordinates and
make it appear where you wish.
Hope it helps.
Good luck.