'**************************************************'Taking Screenshot using word objectSet oWordBasic = CreateObject("Word.Basic")
oWordBasic.SendKeys "{prtsc}" oWordBasic.AppClose "Microsoft Word"Set oWordBasic = Nothing
WScript.Sleep 2000
'Opening Paint Applicationset 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 windowsset shl=createobject("shell.application")
shl.MinimizeAll
WScript.Sleep 1000
shl.UndoMinimizeAll
Set shl=Nothing
WScript.Sleep 1000
'Activating Paint ApplicationWshShell.AppActivate "untitled - Paint"WScript.Sleep 1000
'Paste the captured ScreenshotWshShell.SendKeys "^v"WScript.Sleep 500
'Save ScreenshotWshShell.SendKeys "^s"WScript.Sleep 500
WshShell.SendKeys "c:\test.bmp"WScript.Sleep 500
WshShell.SendKeys "{ENTER}"'Release ObjectsSet WshShell=Nothing
WScript.Quit
'************************************************** 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.
If WshShell.AppActivate "untitled - Paint" statement is working good for you then remove the maximize, minimize script block to save time.
Nice post. Thanks. All your posts are very useful for us.
ReplyDeleteThis is very helpful...Thx Sudhakar for sharing the info..
ReplyDeleteThe 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..
Thx
This is very useful... Thanks ..
ReplyDeleteSuperb Annaya Hatsoff to your site
ReplyDeletePavankumar chennam
Too Good
ReplyDeleteHi Sudhakar,
ReplyDeleteAny 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