3051b2e38d1788f7245d2dcc0a075886809f1d5e
[sdk] / samples / guiAndGfx / screenShot / shot.ec
1 /********************************************************
2    This sample demonstrates takes a screenshot of the
3    desktop and saves it to a bitmap file.
4 ********************************************************/
5 import "ecere"
6
7 class ShotApp : GuiApplication
8 {
9    bool Init()
10    {
11       Bitmap bitmap { };
12       int c;
13       SwitchMode(false, null, 0,0,0, null, false);
14       desktop.Grab(bitmap, null, false);
15       for(c = 0; c<1000; c++)
16       {
17          char fileName[MAX_LOCATION];
18          sprintf(fileName, "shot%02d.png", c);
19          if(!FileExists(fileName))
20          {
21             bitmap.Save(fileName, null, null);
22             break;
23          }
24       }
25       delete bitmap;
26       return true;
27    }
28 }