Take-Screenshot

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.5 Star
(15)
14,581 times
Add to favorites
Multimedia
2/25/2012
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • 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???
  • Take ScreenShot both monitors
    1 Posts | Last post February 14, 2017
    • 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
      image1.png
      image2.png
      image3.png
      
      or
      
      imageYYYYMMDDHHMM.png
      image201702141520.png
      image201702141521.png
      image201702141522.png
      
      
      Any of you could help me please?
      Regards
      Patricio
  • How to make this work?
    1 Posts | Last post October 29, 2016
    • I tried Andreas Kossatz's suggestion but it doesn't work. Well what I did from his suggestion is that I changed the script content the way he suggests and then I made a shortcut of the ps1 file and in the shortcut properties I went under Target and pit:
      
      Z:\Desktop\Take-ScreenShot.ps1 -file z:\desktop\balbla02.png -imagetype png -screen
      
      at least this is what I understood I should do according to his examples:
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png -activewindow (works)
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png -screen (works)
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png (dont works)    
      .\Take-ScreenShot.ps1 -activewindow OR -screen ( only display some information)
      
      or did I misunderstand?
      
      Well, no matter what, as Boe mentioned, there MUST be a how-to article for us noobs,cos I like the idea of simply running this powershell script and generating a screenshot, because I don't want to use any 3rd party tools. I need this cos I have a small bt keyboard and I want to assign one key to take a screenshot. I cannot do it with the program called SharpKeys (though I love it) cos it does not allow the PrntScr key to be swapped. Ofc I managed to achieve what I want with some 3rd party tools but I wanna stay away from those and have sth as simple as a srcrip which executes and maybe doesn't even output a file directly, but instead simply puts the screenshot on my clipboard as the normal PrntScrn key would do. Any ideas?
  • HOW DOES THIS WORK
    2 Posts | Last post June 28, 2016
    • Was sent here to download but all I got was a notepad that opens with a load of fluff and bumpf. So what does this do and how does it work. Running 64 bit windows 10  and UK based and I do not understand technical terms
    • I thought that I had an article about this, but I guess not. I'm currently working to update this function and will have an article to accompany it sometime in the coming weeks. That link will be posted here when it goes live.
  • Need a little more functionality added to it
    1 Posts | Last post March 26, 2016
    • Hi Boe,
      
      I need something similar to this, where it will take a screenshot of an active window and open an new email with the screenshot pasted. Is it possible ?
  • How do I use this?
    2 Posts | Last post February 04, 2016
    • I'm new so how do I use this? I downloaded it but where do I put it? I tried to drag it onto powershell and do a command but it said I had restriction.
    • See my comment from today on the first question.
  • Not working for me
    7 Posts | Last post February 04, 2016
    • I'm not getting an error message but I'm not getting an image either. I'm on Win 7 Pro and PowerShell ISE 3.0. I'm in the same directory (c:\temp) and execution-policy is unrestricted. Any ideas on what else I might be missing?
    • I am getting the same issue, rodchar.  The only difference for me is that I am on Win7 Home
    • I'll have to take a look at this. I honestly have not touched this script in a couple years so I have no doubt that there is something crazy happening.
    • @ Boe Prox : Any update ,since I am also running via Win 7 Home and not getting the desired output.
    • It would be SO SWEET if someone could get this script working again for us novices.  I'm not sure how to debug it, but it executes fine and simply doesn't write out a screenshot.  My command-line appears below.
      
      powershell ./Get-ScreenCapture.ps1 -activewindow -file "C:\Users\clint.sulis\Desktop\WebShot" -imagetype jpeg
      
      Can you spend a little time on this for us Boe?
    • Hello, so now i have fix this script. And now it works for me. Here are my change.
      If you call the Script you need to define on of the two Parameter -screen or -activewindow otherwise it not function. And sorry for my broken english.....
      
      Examples:
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png -activewindow (works)
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png -screen (works)
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png (dont works)    
      .\Take-ScreenShot.ps1 -activewindow OR -screen ( only display some information)
      
      - Change Line 51 and 56 with ParameterSetName = "",
      - change Line 61 with ParameterSetName = "file",
      - Delete Line 1 and 260
      - Replace Line 213-215 with this code:
      #region Import the Assemblies 
      $assm = (
      "System.Windows.Forms",
      "System.Drawing"
      )
      #User Add-Type to import the code
      Add-Type -TypeDefinition $code -ReferencedAssemblies $assm -Language CSharp
      
      Now it should work. if not tell me ....
    • This script defines a function, but does not call it. Maybe in a later version of powershell all the examples here would work, but none of them worked for me. Loading the script merely loads the function, but doesn't execute it. To execute from WITHIN powershell, run:
      . .\Take-Screenshot.ps1                <---- Notice the initial period, it is important
      Take-Screenshot -screen -file bla.bmp  <---- Now you are calling the function, don't use the .ps1 extension
      
      To call it all in one call from a command prompt (or scheduled task):
      powershell -ExecutionPolicy RemoteSigned -Command "& {. .\Take-Screenshot.ps1; Take-Screenshot -screen -file bla.bmp}"
      
      
  • Good Work
    8 Posts | Last post December 02, 2014
    • Thanks for posting this Boe, I have never seen PowerShell code that imports a chunk of C# b4. Doubly cool for posting something that VBScript can't do. 
      
      
      
    • Thanks for this script. 
      Is it possible to extend the script to send the screenshot directly to a printer? 
      I tested a few things but the only thing I could print was:
      
      Tag                  : 
      PhysicalDimension    : {Width=1456, Height=876}
      Size                 : {Width=1456, Height=876}
      Width                : 1456
      Height               : 876
      HorizontalResolution : 96
      VerticalResolution   : 96
      Flags                : 335888
      RawFormat            : [ImageFormat: b96b3caa-0728-11d3-9d7b-0000f81ef32e]
      PixelFormat          : Format32bppRgb
      Palette              : System.Drawing.Imaging.ColorPalette
      FrameDimensionsList  : {7462dc86-6180-4c7e-8e3f-ee7333a7a483}
      PropertyIdList       : {}
      PropertyItems        : {}
      
    • Yes, I actually do that in my password generator form script that is posted out here as well.  If I have time today, I will work to add that functionality into the script. Thanks for the feedback!
    • As requested, I added the ability to send the screen-shot directly to your default printer.
    • Thanks for the updated script, it is printing the image but the image don't scale to fit the paper automatically. 
      It would be great if this also can be included in the script.
      
      Thanks in advance.
      
      Thomas
    • I will take a look at the script and see what I can do about that.  Thanks!
    • Sorry for being eager, but do you plan to add the ability to scale the image to the paper? Thanks in advance.
    • try this :
      
      https://gallery.technet.microsoft.com/WPF-Application-to-capture-fd2b5811