qtp 抓屏并保存

上一篇 / 下一篇  2009-10-21 18:22:51 / 个人分类:我的自动化学习

' captureScreen: capture the screen image and save it as .png
'Imagepath: the image path, such fxpg ,  "D:\ERM\Report\FXBS\FXPG"
'imageSaveName: the image Name

Function captureScreen(Imagepath, imageSaveName)
    Dim reportDay
    Dim imageFormat

    Set ifso = CreateObject("Scripting.FileSystemObject")
    reportDay = cstr(Date)
    imageFormat = ".png"
    imgFolderPath = Imagepath+backslant + reportDay
    
    If ifso.FolderExists(imgFolderPath) Then
        else
        ifso.CreateFolder(imgFolderPath)
    End If

    If ifso.FileExists(imgFolderPath +backslant+ imageSaveName +imageFormat) Then
        imageCout = imageCout +1
        If imageCout = 2 Then
            imageSaveName = imageSaveName + cstr(imageCout)
        End If       

        If imageCout>2 and imageCout =< 10 Then
            imageSaveName = left(imageSaveName, len(imageSaveName)-1) + cstr(imageCout)
        End If

        If imageCout>=10 and imageCout < 100Then
            imageSaveName = left(imageSaveName, len(imageSaveName)-2) + cstr(imageCout)
        End If     
        Set ifso = nothing
       
        captureScreen Imagepath, imageSaveName
       
    else
        desktop.CaptureBitmap imgFolderPath +backslant+ imageSaveName+imageFormat,Ture       
    End If
    Set ifso = nothing
End Function

TAG:

 

评分:0

我来说两句

Open Toolbar