5

I'm using TestComplete. I need to capture a screenshot and place it in a particular folder. How to do this using VBScript?

Helen
  • 87,344
  • 17
  • 243
  • 314
Ramakrishna
  • 68
  • 1
  • 1
  • 9

2 Answers2

2

To capture a desktop screenshot, use the Sys.Desktop.Picture method. To save the resulting image to a file, use its SaveToFile method:

Sys.Desktop.Picture.SaveToFile "E:\screenshot.png"

Alternatively, you can turn on the Test Visualizer to automatically capture screenshots for your test actions.

Helen
  • 87,344
  • 17
  • 243
  • 314
  • @YallaRamakrishna: If it worked for you, please mark it as solution answer so other people will know. – Helen Mar 22 '13 at 08:17
  • Actually i am new user for stack overflow.I really don't know how it will be marked please tell me the procedure. – Ramakrishna Mar 26 '13 at 10:04
  • @YallaRamakrishna: To mark an answer ac accepted, click on the check mark to the left of the answer: http://cdn.sstatic.net/img/faq/faq-accept-answer.png – Helen Mar 26 '13 at 14:47
  • What is "Sys" ? This doesn't worked for me, vbs seems to doesn't recognize it. – nonozor Feb 21 '19 at 18:00
0
Function CaptureScreenShot(ScreenshotPath )  
  'Generate Name of the Image 
  strimgFileName="Img\Img" & Day(Date)& Month(Date) & Year(Date) & Hour(Now) & Minute(Now) & Second(Now) &".jpg"  
  strImgFile= ScreenshotPath & strimgFileName   
  'Capture failure Screen shot 
  Set objPic = Sys.Desktop.Picture()  
  'Save captured Screen shot 
  ExecutionStatus = objPic.SaveToFile(strImgFile)  
  'Return Captured image name
  CaptureScreenShot=".\" & strimgFileName  
End Function    
JLRishe
  • 99,490
  • 19
  • 131
  • 169
Amaresha
  • 1
  • 1