This program takes screenshots a variety of ways. It was written to help technical writers.
- Saves screenshots as jpegs to destination directory with configurable file suffix.
- Enables user to take a screenshot by drawing a rubber band anywhere on the screen.
- Enables user to select any window any take a screenshot (spy++ style window selection).
- Intercepts the printsceen and the alt+printscreen key(s).
This application began as a request from a fellow programmer to figure out the best way to draw a rubber band on the desktop and take a screenshot of the area in the drawn box. After trying a variety of techniques to accomplish this, I ended up using the low-level mouse hook method
(SetWindowsHookEx(WH_MOUSE_LL,...). My colleague was then inundated with other work. I decided to turn the test project into a useful tool on my own time.
Using the Code
Using the application is very simple. There are 2 main ways to select an area/window and take a screenshot. To draw a rubberband, press the "Draw" button, to use the Spy++ style window selector method, press the "Select" button. On the main dialog, there are configurable parameters such as line width which is used when drawing/selecting. The output directory is configurable as well as a file prefix. You may select the output image format from the combobox loaded with all GDI+ supported image formats. All output files are created in the destination directory using the prefix and a date/time stamp for the file name. You can also choose whether or not to minimize the application to the system tray while drawing/selecting. All parameters are stored/loaded from the registry.
The application was written using VS2003 (MFC7). You will find the majority of the code in the "MainDlg.cpp" file. The code demonstrates usage of the following Win32 functions:
SHGetSpecialFolderLocation(hWnd, CSIDL_DESKTOP, ...
Points of Interest
The rubber band drawing code was taken/modified from the MFC
When saving as GIF I noticed the image quality was not the best. I believe this can be fixed by using the GDI+
EncoderParameters object when calling
Image->Save() in the
CMainDlg::SaveImageAs() function. An example of this can be found directly below in the unused (commented out) function
- 2012-06-23 - File Version 184.108.40.206
- Added image type combobox
- Changed rubber band image selection operation to eliminate problem with desktop icons and various applications with the method described here.
- 2011-10-21 - File Version 220.127.116.11
- Initial CodeProject Release