Take a picture of your desktop

Take a picture of your desktop  Script Powerchell


⇓script

function Get-TimedScreenshot
{
    [CmdletBinding()] Param(
        [Parameter(Mandatory=$True)]
        [ValidateScript({Test-Path -Path $_ })]
        [String] $Path,

        [Parameter(Mandatory=$True)]
        [Int32] $Interval,

        [Parameter(Mandatory=$True)]
        [String] $EndTime
    )

    Function Get-Screenshot {
       $ScreenBounds = [Windows.Forms.SystemInformation]::VirtualScreen
       $ScreenshotObject = New-Object Drawing.Bitmap $ScreenBounds.Width, $ScreenBounds.Height
       $DrawingGraphics = [Drawing.Graphics]::FromImage($ScreenshotObject)
       $DrawingGraphics.CopyFromScreen( $ScreenBounds.Location, [Drawing.Point]::Empty, $ScreenBounds.Size)
       $DrawingGraphics.Dispose()
       $ScreenshotObject.Save($FilePath)
       $ScreenshotObject.Dispose()
    }

    Try {

        #load required assembly
        Add-Type -Assembly System.Windows.Forms

        Do {
            #get the current time and build the filename from it
            $Time = (Get-Date)

            [String] $FileName = "$($Time.Month)"
            $FileName += '-'
            $FileName += "$($Time.Day)"
            $FileName += '-'
            $FileName += "$($Time.Year)"
            $FileName += '-'
            $FileName += "$($Time.Hour)"
            $FileName += '-'
            $FileName += "$($Time.Minute)"
            $FileName += '-'
            $FileName += "$($Time.Second)"
            $FileName += '.png'

            [String] $FilePath = (Join-Path $Path $FileName)
            Get-Screenshot

            Start-Sleep -Seconds $Interval
        }

        While ((Get-Date -Format HH:mm) -lt $EndTime)
    }

    Catch {Write-Error $Error[0].ToString() + $Error[0].InvocationInfo.PositionMessage}
}

Get-TimedScreenshot -Path "$env:userprofile\Desktop" -Interval 2 -EndTime 24:00

Related Posts :

  • Skype  Skype is an instant messaging application with video chat, multi-person voice conference, file… Read More...
  • Kodi  Kodi is a cross-platform media center software with various network media protocols supported.… Read More...
  • BraseroBrasero is a CD / DVD burning software. It supports write-once data DVD and any type of CD, and CD m… Read More...
  • BleachBit BleachBit is an open source system cleaning tool with functions of cleaning application residual dat… Read More...
  • Adobe  Adobe Flash Player is a light-weight play plugin for browser. It can be used to present expres… Read More...