I was looking for a simple command-line tool to take a screenshot on Windows, but couldn't find one, so I wrote one. It's available as open source under a BSD license. After that, I wrote basically the same thing for Linux (using GDK). That is available under the same license. See the header of the source code for instructions on how to compile the code.