none
How to capture screen in Metro app??

    Question

  • Hi,

    How can I capture screen from a metro app?

    • In  WPF:

           using (Graphics g = Graphics.FromImage(bitmap))
           {
                  g.CopyFromScreen(SourcePoint, DestinationPoint, 
                 SelectionRectangle.Size);
          }
         bitmap.Save(FilePath, ImageFormat.Jpeg);

    There is an equivalente class to Graphics?

    Best regards

    Friday, March 02, 2012 11:11 AM

Answers

  • No, there is no way for a Metro style app to do this. By design they cannot directly interact with other apps outside of themselves, including capturing screenshots which may include other apps.

    There also isn't a way for a Metro style app to render Xaml elements to a bitmap so you can't readily implement this for your own app.

    --Rob

    Friday, March 02, 2012 3:59 PM
    Owner
  • Sorry, but rendering Xaml to an element or capturing a screenshot of your own app did not make it into the release version.

    It is by design that an app cannot capturing a screenshot of another app.

    --Rob

    Wednesday, August 29, 2012 4:09 AM
    Owner

All replies

  • No, there is no way for a Metro style app to do this. By design they cannot directly interact with other apps outside of themselves, including capturing screenshots which may include other apps.

    There also isn't a way for a Metro style app to render Xaml elements to a bitmap so you can't readily implement this for your own app.

    --Rob

    Friday, March 02, 2012 3:59 PM
    Owner
  • Hi Rob,

    Thanks for your answer,

    After your answer ("... you can't readily implement this for your own app") I was wondering about other ways to try do this (maybe using DirectX).

    In a previous version of DirectX it was possible to capture screen by:

    1-) Create a device and a surface

    2-) Get front buffer data from device and store it in surface [ myDevice->GetFrontBufferData(0, pSurface); ]

    3-) Use D3DXSaveSurfaceToFile to save the surface to file.

    But I couldn't find neither a function to get front bufffer (in ID3D11Device1) nor a function to save the surface to a file in this verson of DirectX.
    Do you have  any clue??

    BR

    Monday, March 05, 2012 5:07 PM
  • Now, hitting the Windows Key and Print Screen at the same time dumps the entirety of your screen to a .PNG file in your Pictures folder.

    Does anyone know how to do this through Metro app?

    BR,

    Carla

    Friday, March 09, 2012 11:29 AM
  • Now, hitting the Windows Key and Print Screen at the same time dumps the entirety of your screen to a .PNG file in your Pictures folder.

    Does anyone know how to do this through Metro app?

    BR,

    Carla

    Carla, not sure if this will help, but at design-time you can get a screen capture from the simulator. (I think that's cool, but obviously won't help with a release app...)

    Rebecca M. Riordan

    Friday, March 09, 2012 1:55 PM
  • Hi Rob, 

    Even with new SwapChainBackgroundPanel is not possible to get a screenshot from a XAML/DirectX application right?

    I created application with SwapChainBackgroundPanel on main page and mixed with the directx sample "save to image file"

    but no xaml ui was saved on image , only the swapchain buffer.

    you have already mentioned that it is not possible, but with this new control I thought the things were changed a little.


    Flavio


    Tuesday, March 13, 2012 12:33 PM
  • Hi Flavio,

    The SwapChainBackgroundPanel control doesn't affect this situation. You can store off the DX buffer, but that occurs before the Xaml controls are composited in.

    --Rob

    Tuesday, March 13, 2012 3:54 PM
    Owner
  • Hi Rob,

    I'm just looking for a solution for screen capture in Metro, so do you mean that screen capture is unavailable in Metro style App and no solution for this? Thanks!


    • Edited by Dongjjing Wednesday, March 21, 2012 1:17 AM
    Wednesday, March 21, 2012 1:16 AM
  • Correct. There is no way for a Metro style app to capture a screenshot.

    --Rob

    Wednesday, March 21, 2012 1:30 AM
    Owner
  • Hi Rob,

    If I want to capture a region in app itself, is there any solution? Thanks!

    Wednesday, March 21, 2012 7:04 AM
  • No. There is no way to render the Xaml elements used by your app to a bitmap.

    --Rob

    Thursday, March 22, 2012 2:54 AM
    Owner
  • That's really sad, because I've used that in my Windows Phone app to create dynamically secondary tiles from my app. That way I can easily save a custom Xaml graphic to a PNG and use it as a background for my start screen tile.
    • Edited by dvlg Thursday, March 22, 2012 4:46 AM
    Thursday, March 22, 2012 4:46 AM
  • While I agree this features is one of the mostly missed ones and I still hope it will show up in a later version - there are a lot of tile templates from which you could choose something that would perhaps fit your needs:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx

    If these are not enough - perhaps you could render the contents you need using something like WriteableBitmapEx (I have a version that works with WinRT). Otherwise - you could render anything with Direct2D and WIC that you can render using XAML UI. I agree that it is a lot of work to achieve the same result - but these are your options for now.


    Filip Skakun

    Thursday, March 22, 2012 6:33 AM
  • If you still care, you are able to make a desktop app that works in conjuction with the metro app, passing the information along, that is if the normal desktop app is able to screen capture metro apps correctly...

    It can just pass all the info to the other program directly either by opening a connection through both apps such as any internet app would but between the two apps on your computer, by writing the pictures to the filesystem & reading the files for display in your metro app, or other methods to get data between the two apps.

    ---This would be at least until it's supported natively or someone finds another way...however by design rob is right, everything is meant to be sandboxed so that they can't do much harm either to other apps directly or interact with them in a way that's not expected...

    Thursday, March 22, 2012 2:10 PM
  • Hi Filip Skakun,

    I have already tried to use Direct2D and WIC to render XAML controls, but I was not successful

    http://social.msdn.microsoft.com/Forums/en-US/wingameswithdirectx/thread/391345b2-2415-4b7d-bac2-2edabc1273bb

    Br,

    C.J. Santos

    Thursday, March 22, 2012 7:30 PM
  • What I meant was - you can draw shapes, text and images using Direct2D. The same shapes that you would otherwise draw with XAML UI. I did not mean to imply that you can render XAML controls - just that you can use Direct2D as an alternative to achieve same results albeit with somewhat more effort.

    Filip Skakun

    Thursday, March 22, 2012 8:17 PM
  • Hi Michael,

    Metro style apps are required to be fully functional stand-alone. They cannot rely on or communicate with desktop apps.

    Filip's suggestion to use low level primitives to draw a facsimile of your controls is the closest to a solution available. I'm quite excited to hear that WriteableBitmapEx has been ported to make this more accessible from C#.

    --Rob

    Friday, March 23, 2012 12:20 AM
    Owner
  • Win Key + Print Screen works just fine.

    ASUS CM-6850 Intel I7-2600 CPU, 16GB RAM, 1 TB HDD, 180 GD Corsair Force 3 SSD, Windows 7 Professional 64 bit. Gateway Laptop 2 GB RAM Windows 8 Release Preview, Office 15 Customer Preview

    Saturday, August 18, 2012 9:49 PM
  • Rob 's answers in customer preview version, but now when RTM version released, can Metro Style App capture a screenshot inside them selves, and may be use background task to capture another app's screenshot?
    • Edited by CuongNC Wednesday, August 29, 2012 2:45 AM
    Wednesday, August 29, 2012 2:26 AM
  • They can't - you still need to render it to the image yourself. As for another app - that is unlikely to be allowed even in a more distant future - you could get apps capturing screenshots of your banking apps, etc. I suspect this might actually be the reason why WriteableBitmap is not available yet - I am speculating, but it could be because it was hard to make it secure.

    Then of course it is more likely that some analytics said it was used by less than 1% of developers or other such b*... nonsense.


    Filip Skakun


    Wednesday, August 29, 2012 3:57 AM
  • Sorry, but rendering Xaml to an element or capturing a screenshot of your own app did not make it into the release version.

    It is by design that an app cannot capturing a screenshot of another app.

    --Rob

    Wednesday, August 29, 2012 4:09 AM
    Owner
  • can i get my app' s screen image?

    让信任简单起来

    Thursday, August 30, 2012 5:44 AM
  • Only if you render it yourself using primitive drawing operations of DirectX or WriteableBitmap.

    Filip Skakun

    Thursday, August 30, 2012 5:58 AM
  • can i use WriteableBitmap in Metro app?

    i can't found it's namespace


    让信任简单起来

    Thursday, August 30, 2012 6:26 AM
  • Hovering over the entered type name usually reveals an icon that you can use to add the missing references. Alt+Shift+F10 does the same thing. The type is in Windows.UI.Xaml.Media.Imaging namespace. You can also find it in the Object Browser (Ctrl+W,J).

    Filip Skakun

    Thursday, August 30, 2012 6:29 AM
  • Rob - all due respect - but we gotta have this... when I first found out about this limitation I was at a loss but we found a way around it for release.  Now we have a 2nd client coming to us for an app and we need the same functionality for different reasons so its critical now.  There's a ton of places this kind of thing is used...  could it be written possibly in c++ then imported as a winrt component to our c# apps?

    best, Ragnasaur

    Thursday, September 06, 2012 1:55 AM
  • Too bad this doesn't work. Most natural thing to put the current state of the app into a bitmap and then implement Undo by showing a list of the screenshots.

    Overal Metro is TOO limited to do real stuff...


    HJ

    Sunday, September 23, 2012 11:17 AM
  • Hi,

    I can't understand how you disable something very important to developers and needed in many apps.

    We can't always wait for new versions to get basic capability. Time is not on our side.

    Please think of developers as they are the people who make the apps for users that encourage them to buy your operating system.

    I hope that someone who has a word in Microsoft think of these words. There are no more second chances.


    elhajjh

    Saturday, October 27, 2012 9:17 PM
  • The same to me! It's important!!!

    I just cant understand why MS remove this even it works in WPF!

    If YOU got reason just tell us Okay?

    I dont know why Windows store just have only 5000 apps and YOU just still REFUSE to help developers?


    It's Lin.

    Monday, October 29, 2012 7:34 AM
  • This is really frustrating,

    We need many functionalities that were available before. Now we are working on very important project that needs the functionality of capturing the screen of our application or capture our own xaml control and converts it to bitmap .


    What shall we do, abort our project after months of working, what to tell the customers ??????


    Microsoft should add this feature in an update as soon as possible, I think they can do it in few days if they want.

    Please HELP.


    elhajjh


    • Edited by elhajjh Tuesday, November 06, 2012 2:41 PM
    Tuesday, November 06, 2012 2:40 PM
  • You can't capture a control, but through the magic of Windows Runtime you should be able to render anything you want to a bitmap using a Direct2D, DirectWrite and Windows Imaging Component. You can even use the SharpDX library to do it using C# as in this sample: https://github.com/christophwille/winrt-snippets/tree/master/RenderTextToBitmap

    Filip Skakun

    Tuesday, November 06, 2012 3:41 PM
  • Does anyone have a usable example of how to do this to a canvas in metro.  This seems a little silly that this is not available when you could do this in Silverlight 3... 

    Nevin Morrison

    Tuesday, November 13, 2012 12:00 AM
  • Metro has great potential; but it seems that Microsoft's decisions are limiting everybody's attempt at using it. Things need to change. I am sick of hearing from people "Hey, why can't your app do this?" and having to respond with "It's not allowed to." And then having to put up with crap like "But desktop apps can" - but I can't release Desktop apps to the Store because I can only get an "Individual" account - when in fact I am a legally-registered Business (but not a Company).

    Back on the subject. You can't take a snapshot of a single element inside your own application? Now that's just ridiculous.


    Tuesday, January 29, 2013 11:06 PM
  • I agree here, this is critical. Customers want it and developers need it. Please reconsider adding this to a future update.
    Tuesday, January 29, 2013 11:12 PM
  • Seriously? I just invested hundred hours++ implementing a new app and was now starting at the "Save as image" feature, and I find out this is not possible! No wonder WinRT-developers are unhappy and no really good apps are showing up... Sorry. 
    Wednesday, March 06, 2013 8:37 PM
  • Yup! Really disappointed! I think it should be easily for us to capture every part of the screen.
    Monday, March 18, 2013 3:10 AM
  • When I use IE 10 (metro version) I can see a thumbnail of the current page displayed in top App Bar.
    What is the mechanism/API IE10 is using to do that?
    Is it possible to create a thumbnail of my own application screen using the same mechanism?

    Monday, April 01, 2013 3:49 PM
  • IE10 cheats.

    Rebecca M. Riordan

    Tuesday, April 02, 2013 11:55 AM
  • The limitation being discussed here is specific to rendering Xaml elements to bitmaps.

    IE does not use Xaml. It does its own rendering. If your app renders its graphics itself then it is not subject to limitations of the Xaml renderer. Many DirectX apps render to bitmaps in this way.

    --Rob

    Monday, April 08, 2013 5:11 PM
    Owner
  • The limitation being discussed here is specific to rendering Xaml elements to bitmaps.

    IE does not use Xaml. It does its own rendering. If your app renders its graphics itself then it is not subject to limitations of the Xaml renderer. Many DirectX apps render to bitmaps in this way.

    --Rob


    LOL. Like I said, IE10 cheats ;)

    Rebecca M. Riordan

    • Proposed as answer by doubleyoueight Monday, April 08, 2013 10:54 PM
    Monday, April 08, 2013 5:16 PM
  • If there is no way to save xaml elements to bitmaps, then what's the purpose of rendering xaml elements? I really think MSFT needs to listen to developers more seriously, Writeablebitmap  is very bad since it doesn't support DrawText (WriteableBitmapEx doesn't support it either).
    Tuesday, April 09, 2013 3:43 AM
  • Hi,  Rob

    Can I capture SurfaceRT Desktop app (like office word) screen using programing?


    Friday, May 10, 2013 3:02 AM
  • Maybe there is a way with the Printing API? Something like "print screen to PDF"? I didn't try it, just an idea...
    Thursday, September 12, 2013 10:14 AM