8 июл. 2010 г.

Скриншот силами PowerShell

Создание скриншота средствами PoweShell

Оригинал спёрт отсюда


[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$size = [Windows.Forms.SystemInformation]::VirtualScree
$bitmap = new-object Drawing.Bitmap $size.width, $size.height
$graphics = [Drawing.Graphics]::FromImage($bitmap)
$graphics.CopyFromScreen($size.location,[Drawing.Point]::Empty, $size.size)
$graphics.Dispose()
$bitmap.Save(".\screenshot.jpg")
$bitmap.Dispose()



Или (спёрто отсюда):

    Add-Type -Assembly System.Windows.Forms
    Sleep 10

    ## Capture the entire screen
    [System.Windows.Forms.Sendkeys]::SendWait("{PrtSc}")

    ## Capture the current window
    [System.Windows.Forms.Sendkeys]::SendWait("%{PrtSc}")

Комментариев нет: