Take a screen shot from command line in Windows
Solution 1
Download imagemagick. Many command line image manipulation tools are included. import allows you to capture some or all of a screen and save the image to a file. For example, to save the entire screen as a jpeg:
import -window root screen.jpeg
If you want to use the mouse to click inside a window or select a screen region & save a a png, just use:
import box.png
Solution 2
This question's already been answered, but I thought I'd throw this in as well. NirCmd (freeware, sadly, not open source) can take screenshots from the command line, in conjunction with the numerous other functions it can do.
Running this from the command line either in nircmd.exe's directory or if you copied it to your system32 folder:
nircmd.exe savescreenshot screen1.png
does what you want. You can also delay it like this:
nircmd.exe cmdwait 2000 savescreenshot screen1.png
That will wait 2000 milliseconds (2 seconds), and then capture and save the screenshot.
Solution 3
it can be done without external tools (you just need installed .net framework ,which is installed by default on everything from vista and above) - screenCapture.bat. It is a selfcompiled C# program and you can save the output in few formats and capture only the active window or the whole screen:
screenCapture- captures the screen or the active window and saves it to a file
Usage:
screenCapture filename.format [WindowTitle]
filename - the file where the screen capture will be saved
format - Bmp,Emf,Exif,Gif,Icon,Jpeg,Png,Tiff and are supported - default is bmp
WindowTitle - instead of capturing the whole screen will capture the only a window with the given title if there's such
Examples:
call screenCapture notepad.jpg "Notepad"
call screenCapture screen.png
Solution 4
Other suggestions are fine -- you could also try MiniCap, which is free and has some other features like flexible file naming and some different capture modes: http://www.donationcoder.com/Software/Mouser/MiniCap/index.html
(disclaimer: I'm the author of MiniCap).
Solution 5
Try IrfanView.
You can run it via command-line. You can specify which window to capture – such as whole window or just the current/active window – and you can also do some basic editing such as sharpening, cropping or resizing the images.
Here are the command line options, particularly interesting is
i_view32 /capture=0 /convert=wholescreen.png
Related videos on Youtube
Željko Filipin
Freelance software engineer. International contractor at the Wikimedia Foundation.
Updated on September 17, 2022Comments
-
Željko Filipin over 1 year
I am looking for a way to take a screenshot of the entire screen from the command line. Operating system is Windows. Something like this:
C:\>screenshot.exe screen1.png
-
Rook over 14 yearsWhy would you want to do something like that ? Apart from the obvious deficiency (it being able to take screenshots only of the command line you're currently working on), what's wrong with the "regular" solutions for such purpose ?
-
Gerd Klima over 14 yearsWhy would it be restricted to take a picture of the cmd line only? I think the question goes more along the lines of automation.
-
Rook over 14 yearsWell, in the moment he wants to take a screenshot, he has to press enter to give the command, doesn't he ? He could of course use a script to time-activate it, but then he's really reinventing hot water.
-
tvCa about 9 years@Idigias: first of all, the screen is larger than a CMD box, but secondly : when a script launches a GUI tool, that GUI tool takes focus. So, your "obvious deficiency" is not obvious, and no deficiency either. Have you ever worked with command line ?
-
mini about 5 yearsTake a look at: p.teknik.io/GXO9X
-
-
jon3laze over 11 yearsThen you must also be the author of Screenshot Captor. I found it a better solution for my needs. Thank you!
-
CMCDragonkai about 10 years@BinaryPhile Yea I think this would only work with an X server running on Cygwin.
-
Jarekczek over 9 yearsThis is open source, BSD license. Very simple and small - for me these are advantages.
-
Thomas Weller about 9 years
Nircmd
does not support multiple screens. It will capture the primary screen only. -
Thomas Weller about 9 yearsThis one supports multiple monitors but adds some extra black area in version 1.5
-
Thomas Weller about 9 yearsThis is now a commercial product, needs .NET and is not released for Windows 7++. The link given in the answer returns HTTP 404.
-
reinierpost over 8 yearsIt still doesn't work for me. I get a screenshot, but only the X applications show up (as expected).
-
w32sh about 8 yearsLooks like the recent versions can do multiple screens. savescreenshotfull [filename]
-
johny why about 8 yearshm, ImageMagick is 25 Mb, and does TON of cool stuff. screenCapture.bat, below, is 9 Kb, and simply does exactly what the OP requested. At .04% the size of ImageMagick.
-
johny why about 8 yearsDefinitely the best solution. Super-tiny 9K! That's 0.04% the size of ImageMagick (25 Mb). It uses built-in Windows functionality. Tinier than all other solutions on this page. Best!
-
F1234k over 7 yearsOne thing that I noticed about this solution is that there are specific things that it does not capture. For example, some applications are attaching themselves and creating huds on other applications that are not rendered in the captured image. In those extreme cases I found that MiniCap works. In most cases though, this solution right here is the fastest and most uncomplicated that you can find.
-
alpha_989 over 6 yearsYea the GitHub repo doesn't exist.
-
alpha_989 over 6 yearsI couldn't find the download link for nircmd2 initially. Google search didn't show anything. For users looking to download
nircmd2
, the download link is located at the very bottom of the page nirsoft.net/utils/nircmd.html. You can directly use this download link: nirsoft.net/utils/nircmd.zip -
domih almost 6 yearsFirst I tried the imagemagic solution, but when I've seen that piece of Python code, I tried it in an interactive Python CLI and a second later I was happy! Thx!!
-
frakman1 over 5 yearsFor those interested in compactness, boxcutter is only 22K for the full-screen .exe and 502K for the regular .exe. It is open-source. Works great for me.
-
mini about 5 yearsHi @npocmaka, I have two monitor that desktop is extended on them. I want to take screenshot of desktop of the second monitor. But your program just take screenshots from primary desktop. Any trick?
-
Bhavini about 5 years@mini - you can edit the c# part of the script using this . I'll try to add add this at the weekend
-
mini about 5 years@npocmaka, As I'm not familiar with C#, I'll be waiting for your update. Thanks a lot.
-
Sankalp almost 5 yearsWhen I run this command using a Powershell client in Python, it always gives me an exception "Probably there's no window like" for almost everything.
-
SparedWhisle over 4 yearsI've using IrfanView for years, never know it could do this. Thanks for sharing.
-
bparker almost 4 yearsDoesn't seem to work for me, it always just outputs a black image regardless of the extension.
-
Bhavini almost 4 years@bparker - what's the version of your .net framework?
-
Roland over 2 years@johnywhy solution with bat file below just 9kb? Does that include the C# compiler and .NET framework called by the script? ImageMagick might be pale compared to compiling that script for each screenshot.
-
Roland over 2 years@johnywhy you are right, because Windows chose not to include ImageMagick, and because you can live without IM, and like MS Paint. All others need to install IM, or GIMP, or whatever, for their graphic needs, and then that script does not have that big advantage over IM.
-
Roland over 2 yearsThis BAT/C# script works great. I would still prefer to build the EXE, and call that from the BAT, but this works. And I learned some more C# and BAT commands. +1
-
johny why over 2 yearsGood point! But correct me if i'm wrong, C# compiler isn't required to use the script. Also i think that script depends on .NET, which is built into Windows anyway. We might as well say "Yes, but the operating system is a dependency. This thing can't run without Windows, and Windows is huge."