gdutlzl 发表于 2012-6-14 16:08:54

用vbs截屏,但总是报错,请高手指导一下,谢谢啦

我把以下代码写到vbs文档里执行,但报Desktop不是对象的错误,具体是啥原因呢?

Dim FileName ,TimeNow, ResPath
ResPath = "C:\Documents and Settings\XP\Desktop\Test Delete"

fileName = ResPath & "" & Now & ".bmp"

Desktop.CaptureBitmap filename,True

gdutlzl 发表于 2012-6-14 16:09:54

Desktop这个object 怎么去创建呢?

026300 发表于 2012-6-14 17:22:15

文件名中不能有冒号吧

gdutlzl 发表于 2012-6-14 23:00:54

ResPath是存储的位置

gdutlzl 发表于 2012-6-14 23:02:54

ResPath = "C:\Documents and Settings\XP\Desktop\Test Delete"
是存储的位置,

gdutlzl 发表于 2012-6-14 23:03:32

ResPath = "C:\Documents and Settings\XP\Desktop\Test Delete"
是图片存储的位置啊

zzxxbb112 发表于 2012-6-15 09:29:17

Desktop是QTP对象,需要在QTP中执行。

gdutlzl 发表于 2012-6-15 09:40:01

果真是的,谢谢4楼的回复,不过有没有办法直接可以在vbs文件中执行的截图方法呢?

SilenceHost 发表于 2012-6-17 21:10:01

vbs隐藏调用qtp呢?

dingheng9546 发表于 2012-6-26 16:04:55

Class JieTu
Function RecoveryFunction1(Object, Method, Arguments, retVal)
Dim FileName ,TimeNow, ResPath
ResPath = "E:/TestsResult/"
TimeNow = DotNetFactory.CreateInstance( "System.DateTime" ).Now.ToString( "ddMMyyHHmmss" )
TestNameNow=environment.Value("TestName")
FileName = ResPath & ""&TestNameNow & TimeNow & ".bmp"
desktop.CaptureBitmapfilename,True
systemutil.closedescendentprocesses
End Function
End Class
我想你应该是想做场景恢复然后截图的。。这是截图代码亲测可用

dingheng9546 发表于 2012-6-26 16:05:03

Class JieTu
Function RecoveryFunction1(Object, Method, Arguments, retVal)
Dim FileName ,TimeNow, ResPath
ResPath = "E:/TestsResult/"
TimeNow = DotNetFactory.CreateInstance( "System.DateTime" ).Now.ToString( "ddMMyyHHmmss" )
TestNameNow=environment.Value("TestName")
FileName = ResPath & ""&TestNameNow & TimeNow & ".bmp"
desktop.CaptureBitmapfilename,True
systemutil.closedescendentprocesses
End Function
End Class
我想你应该是想做场景恢复然后截图的。。这是截图代码亲测可用

dingheng9546 发表于 2012-6-26 16:05:13

Class JieTu
Function RecoveryFunction1(Object, Method, Arguments, retVal)
Dim FileName ,TimeNow, ResPath
ResPath = "E:/TestsResult/"
TimeNow = DotNetFactory.CreateInstance( "System.DateTime" ).Now.ToString( "ddMMyyHHmmss" )
TestNameNow=environment.Value("TestName")
FileName = ResPath & ""&TestNameNow & TimeNow & ".bmp"
desktop.CaptureBitmapfilename,True
systemutil.closedescendentprocesses
End Function
End Class
我想你应该是想做场景恢复然后截图的。。这是截图代码亲测可用

dingheng9546 发表于 2012-6-26 16:05:49

回复 9# SilenceHost
Class JieTu
Function RecoveryFunction1(Object, Method, Arguments, retVal)
Dim FileName ,TimeNow, ResPath
ResPath = "E:/TestsResult/"
TimeNow = DotNetFactory.CreateInstance( "System.DateTime" ).Now.ToString( "ddMMyyHHmmss" )
TestNameNow=environment.Value("TestName")
FileName = ResPath & ""&TestNameNow & TimeNow & ".bmp"
desktop.CaptureBitmapfilename,True
systemutil.closedescendentprocesses
End Function
End Class
我想你应该是想做场景恢复然后截图的。。这是截图代码亲测可用
页: [1]
查看完整版本: 用vbs截屏,但总是报错,请高手指导一下,谢谢啦