Rob van der Woude's Scripting Pages

VBScript Scripting Techniques > OLE Automation > Screenshots

Automate SnagIt screen captures

Automate SnagIt screen captures
VBScript Code:
Option Explicit

Dim objSnagit, strMsg, wshShell

' Check command line arguments (none required)
If WScript.Arguments.Count > 0 Then Syntax

' Capture input type
Const siiDesktop        =  0
Const siiWindow         =  1
Const siiRegion         =  4
Const siiGraphicFile    =  6
Const siiClipboard      =  7
Const siiDOSScreen      =  8
Const siiMenu           =  9
Const siiObject         = 10
Const siiProgramFile    = 11
Const siiFreehand       = 12
Const siiEllipse        = 13
Const siiRoundedRect    = 14
Const siiTriangle       = 15
Const siiPolygon        = 16
Const siiWallpaper      = 17
Const siiCustomScroll   = 18
Const siiTWAIN          = 19
Const siiDirectX        = 20
Const siiExtendedWindow = 23

' Window selection method
Const swsmInteractive   =  0
Const swsmActive        =  1
Const swsmHandle        =  2
Const swsmPoint         =  3

' Capture output type
Const sioPrinter        =  1
Const sioFile           =  2
Const sioClipboard      =  4
Const sioMail           =  8
Const sioFTP            = 32

' Output image type
Const siftBMP           =  0
Const siftPCX           =  1
Const siftTIFF          =  2
Const siftJPEG          =  3
Const siftGIF           =  4
Const siftPNG           =  5
Const siftTGA           =  6

' Output color depth
Const sicdAuto          =  0
Const sicd1Bit          =  1
Const sicd2Bit          =  2
Const sicd3Bit          =  3
Const sicd4Bit          =  4
Const sicd5Bit          =  5
Const sicd6Bit          =  6
Const sicd7Bit          =  7
Const sicd8Bit          =  8
Const sicd16Bit         = 16
Const sicd24Bit         = 24
Const sicd32Bit         = 32

' Output file naming method
Const sofnmPrompt       =  0
Const sofnmFixed        =  1
Const sofnmAuto         =  2


' Create the required objects
Set objSnagit = CreateObject( "SNAGIT.ImageCapture.1" )
Set wshShell  = CreateObject( "WScript.Shell" )

' Set input options
objSnagit.Input         = siiDesktop
objSnagit.IncludeCursor = True

' Set output options
objSnagit.Output                           = sioFile
objSnagit.OutputImageFile.FileType         = siftPNG
objSnagit.OutputImageFile.ColorDepth       = sicd32Bit
objSnagit.OutputImageFile.FileNamingMethod = sofnmFixed
objSnagit.OutputImageFile.Filename         = "snagtest"
objSnagit.OutputImageFile.Directory        = "C:\"

' Capture
objSnagit.Capture

' Launch the captured image in the default viewer
wshShell.Run "C:\snagtest.png", 0, False

' Release the objects
Set objSnagit = Nothing
Set wshShell  = Nothing


Sub Syntax
    strMsg = vbCrLf _
           & WScript.ScriptName & ",  Version 1.01" _
           & vbCrLf _
           & "Automate a SnagIt full screen capture" _
           & vbCrLf & vbCrLf _
           & "Usage:  " & UCase( WScript.ScriptName ) _
           & vbCrLf & vbCrLf _
           & "Notes:  [1] The resulting screenshot is saved as C:\snagtest.png." _
           & vbCrLf _
           & "            An existing file will be overwritten." _
           & vbCrLf _
           & "        [2] This script requires SnagIt to be installed on the local computer." _
           & vbCrLf _
           & "            SnagIt is commercial screen capture software by TechSmith." _
           & vbCrLf _
           & "            A 30-day trial version is available for download:" _
           & vbCrLf _
           & "            http://www.techsmith.com/screen-capture.asp" _
           & vbCrLf & vbCrLf _
           & "Written by Rob van der Woude" _
           & vbCrLf _
           & "http://www.robvanderwoude.com"
    WScript.Echo strMsg
    WScript.Quit 1
End Sub
Requirements:
Windows version: any
Network: any
Client software: SnagIt (tested with versions 7.2.5 and 8.2.3)
Script Engine: any
Summarized: Works in any Windows version, as long as SnagIt is installed.
 
[Back to the top of this page]

 

This demo script can be downloaded here.


page last modified: 2022-10-25; loaded in 0.0013 seconds

SnagIt