For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
An important update from QtpSudhakar. I stopped giving classroom training in MindQ Systems. I have bigger plans and I want to put an end to regular classroom training because very less people are practicing. From now onwards every session of mine is going to have explanation and practice. Everyone should practice in presence of mine and should go out of classroom with practical knowledge. So I started my own institute AnyTechLabs in Madhapur. Please reach out to +91-8328152362 for course details. Visit AnyTechLabs.com for address details.
Selenium + Cucumber 24th October 7.30 AM IST to 9.00 AM IST 45 Days WeekDay Online

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Wednesday, June 17, 2009

How to take screenshot using VBScript?

'Taking Screenshot using word object
Set oWordBasic = CreateObject("Word.Basic")
oWordBasic.SendKeys "{prtsc}" 
oWordBasic.AppClose "Microsoft Word"
Set oWordBasic = Nothing
WScript.Sleep 2000
'Opening Paint Application
set WshShell = CreateObject("WScript.Shell")
WshShell.Run "mspaint"
WScript.Sleep 2000
'Some times Paint Application is not activating properly
'To activate MS Paint properly i have minimized and restored the opened windows
set shl=createobject("shell.application")  
WScript.Sleep 1000
Set shl=Nothing
WScript.Sleep 1000
'Activating Paint Application
WshShell.AppActivate "untitled - Paint"
WScript.Sleep 1000
'Paste the captured Screenshot
WshShell.SendKeys "^v"
WScript.Sleep 500
'Save Screenshot
WshShell.SendKeys "^s"
WScript.Sleep 500
WshShell.SendKeys "c:\test.bmp"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
'Release Objects
Set WshShell=Nothing

I got some issues when i have activated using WshShell.AppActivate "untitled - Paint".
Then I tried minimizing and Restoring the opened windows using shell.Application and its working fine.
WshShell.AppActivate "untitled - Paint" statement is working good for you then remove the maximize, minimize script block to save time.


  1. Nice post. Thanks. All your posts are very useful for us.

  2. This is very helpful...Thx Sudhakar for sharing the info..

    The only thing of puzzle is why we require to use Word Object to take the screenshot, I observed that if we do not use word object then screenshot cannot be taken or its blank..

  3. This is very useful... Thanks ..

  4. Superb Annaya Hatsoff to your site

    Pavankumar chennam

  5. Hi Sudhakar,

    Any idea how to capture screen shot from a machine where MS Word is not installed, I need to access a URL from a server and then capture it's screen shot for every 15 min, is there a way for this