Skip to content

Instantly share code, notes, and snippets.

@justfdot
Created March 31, 2023 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justfdot/30f494faa7be8b09970b826f4accf095 to your computer and use it in GitHub Desktop.
Save justfdot/30f494faa7be8b09970b826f4accf095 to your computer and use it in GitHub Desktop.
Shot
Add-Type -AssemblyName System.Windows.Forms, System.Drawing
$destination = "\\HOME-PC\Share\"
if(!(Test-Path $destination)) {
# server's not respond, do something
}
$destination += $env:COMPUTERNAME
if(!(Test-Path $destination)) {
New-Item -ItemType Directory -Force -Path $destination
}
$destination += "\" + (Get-Date -f dd.MM.yy)
if(!(Test-Path $destination)) {
New-Item -ItemType Directory -Force -Path $destination
}
$screen = [Windows.Forms.Screen]::PrimaryScreen.Bounds
while ($true) {
Start-Sleep -Seconds 1
$image = New-Object System.Drawing.Bitmap ($screen.width), ($screen.height)
$graphics = [Drawing.Graphics]::FromImage($image)
$point = [Drawing.Point]::Empty
$graphics.CopyFromScreen($point, $point, $image.Size)
$image.Save(
"$destination\$(Get-Date -f HH.mm.ss).png",
[Drawing.Imaging.ImageFormat]::Png
)
$graphics.Dispose()
$image.Dispose()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment