Link to home
Start Free TrialLog in
Avatar of gleznov
gleznov

asked on

Background app that takes screenshots

Hi,

     1) I would like to have a background application that runs without any visible windows.

      2) I would like this app to take a screenshot once every 5 - 60 minutes, depending on user settings, and save it to a directory.  A counter in a text file will determine unique names for each bitmap.  

       I know I've read something about background process apps before, but I don't know how to create one.  I'm also guessing sending windows a command to take a screenshot (same as hitting Print Screen button and saving the result) is pretty simple, but have no idea how to do it.

Thanks!

JP
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow Idle_Mind did it all
just to add one more thing..

If you dont want to show it at all, not even in the taskbar, make it a Windows Service
Avatar of gleznov
gleznov

ASKER

Thank you both!
Any chance this could be compiled and posted somewhere online?
Would be very much appreciated.
J
It works fine, but when I run it as Windows Service, I got interop GDI+ error when calling the save function. Any idea? Thanks :Ol

Error: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
   at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
   at System.Drawing.Image.Save(String filename, ImageFormat format)
   at System.Drawing.Image.Save(String filename)
   at ScreenShots.Service.takeScreenShot()

The System Service started saving ScreenShots, when I used strong name, registered it in GAC and set file system writing rights to the System Service user.

But all ScreenShots are black. It didn't change when I tried to save it in JPG format. Still black. Any idea? Thanks :Ol
if you are taking pictures of a running Movie in media player,
It cannot be screen shoted. As it is written directly into memory.

Even print screen cannot take it
All right, but still I don't understand why the above described screenshoting solution works as WinForm Application, but not as System Service. Even when the System Service run under user, which is equal to logged on user.
Print Screen in Vista+ will show screen shot output of Media Player provided it is not DRM content. Also the reason you get a black screen when taking a screen shot from a service is because the service runs in Session 0 which is the secure desktop so you are not going to get a picture of what is going on with the active logged on session. Your best bet for what you are doing is to create a standalone application and set the showintasktray attribute of your form to false and hige the window (.hide()). Good luck!