怎么分别用VBS和QTP自带的函数库截屏,求高手。
我想分别用vbs和QTP截屏,请高手给一下各自的代码吧。最好能讲解一下,非常感激 object.CaptureBitmap Filename,object 可以是Desktop,也可以是具体的对象,如Browser("。。。").Dialog("。。。")
如果使用Desktop将截整个桌面,具体的对象则截具体对象作为图片
filename 是截图后保存的文件名
OverrideExisting是可选项,指示是否覆盖同名文件,设置为True将覆盖,默认为False,不覆盖 参考如下脚本
Dim PathWay,myTime,FileName
PathWay="d:\testing\"
myTime=now( )
TimeStamp=year(myTime)&"y"&month(myTime)&"m"&day(myTime)&"d"&hour(myTime)&"h"&minute(myTime)&"min"&second(now)&"s"
FileName=PathWay&TimeStamp&".bmp"
Desktop.CaptureBitmap FileName 不知道两种截图后的效果有何不同 , 什么样的需求导致要这样实现, Ths 回复 4# Jun_Li
你自己写段代码试试就知道,Desktop是截整个桌面,而具体的object是截具体的对象,如窗口,按钮等,至于什么样的需求,就是根据需要了 VBS调用SnagIt的组件进行截屏的代码:
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: The resulting screenshot is saved as C:\snagtest.png." _
& vbCrLf _
& " An existing file will be overwritten." _
& vbCrLf _
& " 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 回复Jun_Li
你自己写段代码试试就知道,Desktop是截整个桌面,而具体的object是截具体的对象,如窗 ...
rojer521 发表于 2010-9-19 20:19 http://bbs.51testing.com/images/common/back.gif
其实这个意思呢,就是说
Desktop就是按print
object就是按Alt+print 那如果VBS调用ScreenCapture函数时,是怎么执行的呢? 那如果VBS调用ScreenCapture函数时,是怎么执行的呢?
yunbin_7 发表于 2011-5-19 14:23 http://bbs.51testing.com/images/common/back.gif
TIB不是说得很清楚了么
页:
[1]