Archived

This topic is now archived and is closed to further replies.

Fuzztrek

"Stealing" screenshots

Recommended Posts

eheh.. let me explain. I''m writting a little app to grab screenshots every so often and save the image. I plan to impliment the ability to upload those screenshots to a remote location after I get the basic functionality of the app down. The "purpose" of this application is to periodically take screenshots from games and post them on the web - sort of a poor-man''s streaming video. If nothing else I''m learning a lot while creating it This has been popular with the World of Warcraft Beta - there are pay programs out there that do this, but they are overpriced in my opinion and lack features. This is so far not prohibited by Blizzard, at least, they said it was neat, so I don''t think I''m doing anything illegal So I''ve seen the gazillions of posts about capturing the screen, but very little information on grabbing something rendered by another application. As far as I know GDI will grab the screen no matter what, however after reading this article at codeproject I thought I would look into capturing the screen with DirectX, as the article notes that it is much faster than GDI. I''m a little concerned, though, as not only can World of Warcraft be run in either D3D or OpenGL mode, it can also be run in either a window or fullscreen (if fullscreen, it can be run at different resolutions.) By capturing the screen with DirectX, it looks as though I''ll have to create D3D device - ontop of the one created by WoW. Is this a good idea? Will it slow things down considerably? Or will it not matter because I am not doing any rendering? Furthermore, is there anyway to figure out what the current resolution of the screen is? I don''t want my program crashing or trying to access an area of the screen that isn''t being rendered to because WoW is running in fullscreen at a lower resolution than the desktop is. I don''t mind sticking to GDI if that''s the only option, but I would like some input if possible. Thanks!

Share this post


Link to post
Share on other sites
If you''re running in fullscreen mode you (probably) can''t use the D3D method. In Fullscreen mode WoW and other applications take Exclusive Control over the graphics device. This means no other D3D devices can access the device. If you try to initialize a new device on that same adapter (to take the screenshot) the other device enters its "lost" state and will no longer display anything to the screen until it is reset, which will then cause the device you created to enter it''s "lost" state, so you can''t access anything on the screen until you reset your device, which will then make the other program''s device enter it''s lost state, ad infinitum.

At least, that''s my understanding of the exclusive control, you can always try it and find out.

Share this post


Link to post
Share on other sites
Thanks for replying I''ll see if I can get my app to work with GDI first, and then I might test out D3D and see if that works or not. Other suggestions are welcome

Share this post


Link to post
Share on other sites
I seem to recall something about a BitBlt happening when you call IDirect3DDevice9->Present() in windowed mode. I had some code that accidentally destroyed a window, then called Present before breaking out of the loop and the debug spew complained about BitBlt failing because of an invalid hWnd, so maybe you can grab the contents of a D3D client area using GDI and HDCs?

------------
- outRider -

Share this post


Link to post
Share on other sites
Perhaps its even simpler then this?

If the game allows outputting a screenshot to a file (which most games support, don''t know why WoW wouldnt) then it should just be a matter of writing a simple script which monitors the folder where screen shot files are put and then uploads them.
Something written in python would be more then enough for that. (Check out python.org docs to see how)

Anyway, if the game doesnt natively support writing to a file then this post isnt very relevant. My bad. (Though game isnt very well thought out)

Cheers,
- Jacob

Share this post


Link to post
Share on other sites
WoW does have it''s own screenshot capabilities, however you cannot access them from in-game scripts. So, the person running the application would continually have to press the print-screen key in order to get the required functionality. Furthermore, WoW saves it''s screenshots as TGA, so I would have to convert them before uploading them (not a big deal, but TGA''s are rather large to be moving around every few seconds.)

If I didn''t mention it before, I am aiming to take a screenshot once every few seconds - my current min/max is 5 to 300 (seconds.)

Share this post


Link to post
Share on other sites
Why not write the script.

Send print screen to app every interval, and then wait, convert file to .jpg, and upload it.

Wouldnt want more then a screenshot every few seconds with that system, but hey it would only take an hour or so to write.

You would be amazed at the power of python

Anyway, enough python advertising. You probobly get the point

- Jacob

Share this post


Link to post
Share on other sites
I''ll say it again...

The script method does not work because the whole purpose of this program is to take a screenshot every few seconds. I want people to be able to run this program on their comp, without having to contstantly press prtscrn. It''s kind of an "automated" prtscrn key-presser. My hope was that I would be able to find a faster method of capturing the screen, but it looks as though I''ll have to settle with GDI.

Share this post


Link to post
Share on other sites
I think Kevlar-X was suggesting that you make a program that automatically sends the print screen command to the game. You''d probably do this with a SendMessage() call or something.

And as for getting screen resolution, look up GetSystemMetrics().


int Agony() { return *((int*)0); }    Mwahaha... >8)

Share this post


Link to post
Share on other sites
Hmm.. I might try sending the message.. Hopefully it wouldn''t slow the game down too much, since I would be converting it in another process.

Share this post


Link to post
Share on other sites