This script has a function that allows you to take a screenshot of the entire desktop or of an active window. Also includes option to save the screenshot to a file.

4.6 Star
28,395 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question

  • How to debug the c# part of that script?
    2 Posts | Last post March 19, 2019
    • How to debug the C# Code of that script and step through the C# Code with the Visual Studio Code debugger?
    • GetForegroundWindow() doesn’t work correctly 
  • How to use script?
    2 Posts | Last post March 17, 2019
    • I run script but there is no output. What should I do?
    • Run PowerShell with elevated permissions an enter:
          Set-ExecutionPolicy Bypass
  • Take ScreenShot both monitors
    2 Posts | Last post April 10, 2018
    • How can I use this script to take snapshots of my both monitors?
      This command only take the primary monitor and I need both screens
      .\Take-ScreenShot -screen -file "D:\image.png" -imagetype png
      And I need to save all files with diferents names or date like
      Any of you could help me please?
    • I have the same issue... need to capture from 2 monitors. Did you find any solution?
  • No output, no errors either
    2 Posts | Last post March 07, 2018
    • I run the script, but get no output.  No errors either, but no output.
    • Figured out my own question based on some other posts here.  This is probably obvious to people who are intimately familiar with PowerShell, but for a beginner this was confusing.  Mostly it came down to being hard to read.
      The key was the post by Phoenix Integration on Febrary 4, 2016, so I build on their post.  But even with that, it took me a bit more to figure out.
      As Phoenix Integration indicates, assuming you're already at a PowerShell prompt, and assuming your current directory is already set to the same directory where the .ps1 script is stored, it takes TWO commands to make this run:
         .  .\Take-Screenshot.ps1   <--Note, NO parameters, and the initial period
         Take-ScreenShot -screen -file bla.bmp   <--whatever parameters you need, NO .ps1 extension
      After seeing Phoenix Integration's post, the command lines presented on the Description tab of this script finally made sense to me.
      The second key piece is that in the first command line, there is a "space" between the two periods at the beginning.  If you don't already know this by being familiar with PowerShell, it's hard to tell this from seeing it typed on the screen.  I couldn't see the space at all in Phoenix Integration's post.  It's a bit more noticeable in the command line on the Description tab, but again, if you don't already know that there is supposed to be a space between them, it could be easily overlooked in reading the Description tab command line listing.
      Then also, as Phoenix Integration posted, if you try to script it to run automated, use this command line (copy & pated directly from Phoenix Integration's post):
      powershell -ExecutionPolicy RemoteSigned -Command "& {. .\Take-Screenshot.ps1; Take-Screenshot -screen -file bla.bmp}"
  • Screenshot is Blacked out
    3 Posts | Last post January 04, 2018
    • I'm trying to use this script to take screenshots on test stations where there is no monitor connected or active RDP running. Only sometimes I get the full screen most of the times blacked out. It works perfectly when desktop is viewed using RDP or via vga connected monitor. 
      Has anyone come across this issue before?
      Any help is much appreciated.
    • Solution for this problem can be found here:
    • I am having the same problem, but the solution provided by vsock didn't apply.
      Basically, I am having a powershell scrip open a program, call the print screen function, open the next program, call the print screen functions, etc.  If I open a standard program (IE explorer.exe), it works fine.  If I open a Windows 8/10 app (IE mail), I get a black image.
  • Remote Screenshot
    1 Posts | Last post August 17, 2017
    • Anyway to use this to get a remote screenshot? No matter if you copy the script and get the logged in session and capture or some other means?
  • It isn't working
    3 Posts | Last post July 27, 2017
    • C:\Users\xyz\Downloads>Take-ScreenShot -screen -file "C:\image.png" -imagetyp
      e png
      'Take-ScreenShot' is not recognized as an internal or external command,
      operable program or batch file.
      Windows PowerShell
      Copyright (C) 2009 Microsoft Corporation. All rights reserved.
      PS C:\Users\xyz\Downloads> Take-ScreenShot -screen -file "C:\image.png" -imag
      etype png
      The term 'Take-ScreenShot' is not recognized as the name of a cmdlet, function,
       script file, or operable program. Check the spelling of the name, or if a path
       was included, verify that the path is correct and try again.
      At line:1 char:16
      + Take-ScreenShot <<<<  -screen -file "C:\image.png" -imagetype png
          + CategoryInfo          : ObjectNotFound: (Take-ScreenShot:String) [], Com
          + FullyQualifiedErrorId : CommandNotFoundException
      Am I missing anything here.
    • Sorry User error.It is working now.
    • same for me, thanks!
  • have an issue with screenshot in WPF app
    1 Posts | Last post July 27, 2017
    • I'm curious, if you are able to provide a solution of following issue?
  • Problem when taking Screen shots in 4k
    1 Posts | Last post May 05, 2017
    • First of all thank you very much to Boe for this very good script.
      It works fine for me with resolutions up to Full HD (1920x1080).
      Meanwhile I wanted to have the need to take some very accurate shots of some windows.
      I picked up a 4k (3840 × 2160) monitor and repeated the process I used to do.
      The strange thing is that the images get cropped !
      When doing a screen shot of the active window the images only have 2400x1350 !!!
      I'm not a C# expert but I went through the C# code of "private Image CaptureWindow(IntPtr handle)" and could not see any kind of limit in the size of the capture image.
      Is there any other kind of limit I'm not seeing ?
      Can you help me on that ?
      Thank you very much.
      Kind regards,
  • Strange Issue w/ This Script
    1 Posts | Last post March 07, 2017
    • Okay, so I have successfully managed to get the script to run as described here for the most part. I'm running it on a Windows 10 machine and it works flawlessly as long as the output is to a local file. No issues there. 
      The strange thing is when I attempt to save the output to a mapped drive or network share either by the share name or IP address, I get an error in Powershell. I'm not in that particular machine at the moment so I can't post it yet. I have the task setup to repeat every minute so that I am getting continuous updates of the active window. Here's the really weird part about it, I will get the error continuously until I manually open Task Scheduler, then the error goes away and the script works perfectly. I don't even have to open the task. I just open Task Scheduler. I can immediately close it and it will continue to work perfectly until the machine reboots. Out of frustration I even attempted to create a task in TS that automatically launches Task Scheduler before the Take-Screenshot script runs and it has no effect. I have to manually launch Task Scheduler and it works fine. Again, when I save it locally this problem doesn't exist. Only when saved to a network location. 
      Any ideas???
1 - 10 of 16 Items