views:

660

answers:

3

I've got an application that is very graphics intensive and built on DirectX and Windows Forms. It has an automation and replay framework around which is built an automated testing system. Unfortunately, when the tests run unattended during a nightly build, the display is inactive or tied up with the screensaver, and our IT security policies don't allow us to disable that.

So my question: is there a way to do a "screen" capture of an application that is running without the display? I'd like to ensure that the graphics card is engaged so that my rendering pipeline is the same, but the testing framework shouldn't need to care about the state of the display.

Any help wildly appreciated!

A: 

Install a VM and run the application in that. If you're running a screen saver I doubt your video card is even generating the GUI for the application.

tloach
A: 

If I understand correct, all you want to to is take a screen grab of a specific application and not have the result be affected by a possibly running screensaver? As far as I know, simply doing GetDIBits on the HDC of the correct window should do the trick and not care about the screensaver.

korona
Doing so will capture what ever is onscreen, which should include screen saver. I haven't prove test this, but I used this method to capture what ever that's ontop of our appication as a composite capture, more like "print screen"
faulty
I'm pretty sure you're wrong, but I'd have to cook up some test code to prove it ;)
korona
+2  A: 

Since you're mentioned rendering pipeline, so I'm assuming you're using Direct3d, if so, you can save the backbuffer of the frame. I did that when I was still using VB.Net + MDX

Dim tempSurface As Direct3D.Surface
tempSurface = device.GetBackBuffer(0, 0, Direct3D.BackBufferType.Mono)
Direct3D.SurfaceLoader.Save(tempFilename, Direct3D.ImageFileFormat.Png, tempSurface)

You can easily converted that do any programming language of you choice, it's basically calling Direct3d's API. Though, you need to configure you backbuffer and Present parameters as

' Need to use flip to enable screen capture
presentParams.SwapEffect = Direct3D.SwapEffect.Flip 
presentParams.PresentationInterval = Direct3D.PresentInterval.One
faulty
Could you also show what you would use as a full declaration for PresentParameters and the Device? I've been trying to make a screen recorder for two days using D3D, and I've had no luck. Using the small snippets you provided I keep getting InvalidCallException in my Device constructor
David Anderson
I'll need to do some digging for that. For the mean time, have you turn on Debug mode for you DirectX runtime? If so, try to look at the debug messages (using DebugView), it will tell you which parameter conflict with the 2 above. As I know, a few of the parameters need to work in certain combo. If it still won't work out, I'll try to post the code tomorrow
faulty