Code covered by the BSD License  

Highlights from
SnagIt

image thumbnail
from SnagIt by Matthew Simoneau
Capture the current window to an image file.

snagIt(filename)
function location = snagIt(filename)
%SNAGIT Capture the current window to a file.
%
%   SNAGIT saves "snagged.gif" in the current directory.
%
%   SNAGIT('C:\path\filename.ext') saves "filename.ext" in the directory
%   "C:\path" with a file type that matches "ext".  The default path is the
%   current directory, the default filename is "snagged.gif".  "ext" can be
%   either bmp, pcx, tif, jpg, gif, or tga.
%
%   LOCATION = SNAGIT(...) returns the full path to the output file.
%
%   REQUIREMENTS: A Windows system with SnagIt, commercial software from
%   TechSmith, installed.  SnagIt is available at <http://www.techsmith.com>.

% Matthew J. Simoneau, April 21, 2003
% Copyright 2003 The MathWorks, Inc.

if (nargin == 0)
   filename = '';
end
[pathstr,name,ext] = fileparts(filename);
if isempty(pathstr)
   pathstr = pwd;
end
if isempty(name)
   name = 'snagged';
end
if isempty(ext)
   ext = '.gif';
end

switch ext
   case '.bmp'
      type  = 'siftBMP';
   case '.pcx'
      type  = 'siftPCX';
   case '.tif'
      type  = 'siftTIFF';
   case '.jpg'
      type  = 'siftJPEG';
   case '.gif'
      type  = 'siftGIF';
   case '.png'
      type  = 'siftPNG';
   case '.tga'
      type  = 'siftTGA';
   otherwise
      error('Unknown Format')
end


imageCapture = actxserver('SnagIt.ImageCapture');
inputWindowOptions = get(imageCapture,'InputWindowOptions');
selectionMethod = get(inputWindowOptions,'SelectionMethod');
set(inputWindowOptions,'SelectionMethod','swsmActive');

imageCapture.OutputImageFile.FileType = type;
imageCapture.OutputImageFile.FileNamingMethod = 'sofnmFixed';
imageCapture.OutputImageFile.Directory = pathstr;
imageCapture.OutputImageFile.Filename = name;
imageCapture.Capture;

location = fullfile(pathstr,[name ext]);

Contact us at files@mathworks.com