Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for snagtest.vbs

(view source code of snagtest.vbs as plain text)

  1. Option Explicit
  2.  
  3. Dim objSnagit, strMsg, wshShell
  4.  
  5. ' Check command line arguments (none required)
  6. If WScript.Arguments.Count > 0 Then Syntax
  7.  
  8. ' Capture input type
  9. Const siiDesktop        =  0
  10. Const siiWindow         =  1
  11. Const siiRegion         =  4
  12. Const siiGraphicFile    =  6
  13. Const siiClipboard      =  7
  14. Const siiDOSScreen      =  8
  15. Const siiMenu           =  9
  16. Const siiObject         = 10
  17. Const siiProgramFile    = 11
  18. Const siiFreehand       = 12
  19. Const siiEllipse        = 13
  20. Const siiRoundedRect    = 14
  21. Const siiTriangle       = 15
  22. Const siiPolygon        = 16
  23. Const siiWallpaper      = 17
  24. Const siiCustomScroll   = 18
  25. Const siiTWAIN          = 19
  26. Const siiDirectX        = 20
  27. Const siiExtendedWindow = 23
  28.  
  29. ' Window selection method
  30. Const swsmInteractive   =  0
  31. Const swsmActive        =  1
  32. Const swsmHandle        =  2
  33. Const swsmPoint         =  3
  34.  
  35. ' Capture output type
  36. Const sioPrinter        =  1
  37. Const sioFile           =  2
  38. Const sioClipboard      =  4
  39. Const sioMail           =  8
  40. Const sioFTP            = 32
  41.  
  42. ' Output image type
  43. Const siftBMP           =  0
  44. Const siftPCX           =  1
  45. Const siftTIFF          =  2
  46. Const siftJPEG          =  3
  47. Const siftGIF           =  4
  48. Const siftPNG           =  5
  49. Const siftTGA           =  6
  50.  
  51. ' Output color depth
  52. Const sicdAuto          =  0
  53. Const sicd1Bit          =  1
  54. Const sicd2Bit          =  2
  55. Const sicd3Bit          =  3
  56. Const sicd4Bit          =  4
  57. Const sicd5Bit          =  5
  58. Const sicd6Bit          =  6
  59. Const sicd7Bit          =  7
  60. Const sicd8Bit          =  8
  61. Const sicd16Bit         = 16
  62. Const sicd24Bit         = 24
  63. Const sicd32Bit         = 32
  64.  
  65. ' Output file naming method
  66. Const sofnmPrompt       =  0
  67. Const sofnmFixed        =  1
  68. Const sofnmAuto         =  2
  69.  
  70.  
  71. ' Create the required objects
  72. Set objSnagit = CreateObject( "SNAGIT.ImageCapture.1" )
  73. Set wshShell  = CreateObject( "WScript.Shell" )
  74.  
  75. ' Set input options
  76. objSnagit.Input         = siiDesktop
  77. objSnagit.IncludeCursor = True
  78.  
  79. ' Set output options
  80. objSnagit.Output                           = sioFile
  81. objSnagit.OutputImageFile.FileType         = siftPNG
  82. objSnagit.OutputImageFile.ColorDepth       = sicd32Bit
  83. objSnagit.OutputImageFile.FileNamingMethod = sofnmFixed
  84. objSnagit.OutputImageFile.Filename         = "snagtest"
  85. objSnagit.OutputImageFile.Directory        = "C:\"
  86.  
  87. ' Capture
  88. objSnagit.Capture
  89.  
  90. ' Launch the captured image in the default viewer
  91. wshShell.Run "C:\snagtest.png", 0, False
  92.  
  93. ' Release the objects
  94. Set objSnagit = Nothing
  95. Set wshShell  = Nothing
  96.  
  97.  
  98. Sub Syntax
  99. 	strMsg = vbCrLf _
  100. 	       & WScript.ScriptName & ",  Version 1.01" _
  101. 	       & vbCrLf _
  102. 	       & "Automate a SnagIt full screen capture" _
  103. 	       & vbCrLf & vbCrLf _
  104. 	       & "Usage:  " & UCase( WScript.ScriptName ) _
  105. 	       & vbCrLf & vbCrLf _
  106. 	       & "Notes:  [1] The resulting screenshot is saved as C:\snagtest.png." _
  107. 	       & vbCrLf _
  108. 	       & "            An existing file will be overwritten." _
  109. 	       & vbCrLf _
  110. 	       & "        [2] This script requires SnagIt to be installed on the local computer." _
  111. 	       & vbCrLf _
  112. 	       & "            SnagIt is commercial screen capture software by TechSmith." _
  113. 	       & vbCrLf _
  114. 	       & "            A 30-day trial version is available for download:" _
  115. 	       & vbCrLf _
  116. 	       & "            http://www.techsmith.com/screen-capture.asp" _
  117. 	       & vbCrLf & vbCrLf _
  118. 	       & "Written by Rob van der Woude" _
  119. 	       & vbCrLf _
  120. 	       & "http://www.robvanderwoude.com"
  121. 	WScript.Echo strMsg
  122. 	WScript.Quit 1
  123. End Sub
  124.  

page last uploaded: 2017-08-21, 14:26