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.

 
 
 
 
 
(15)
12,982 times
Add to favorites
Multimedia
2/25/2012
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • 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 29, 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