Sie sind auf Seite 1von 2

'=============================================================================== ======================== 'Date: 4/5/2012 ' 'Script Name: vbSnagIt.

vbs [Similar to Snagit application, but standalone & can be called from any where ' 'Author: Ram ' 'Approved: XXXXXXX ' 'Team: Corp Finance ' 'Function: Taking Screenshot using word object, since you cannot use sendkeys ' from shell to another application. Right now it is in full GUI mode, which can be minimized ' to take background shots and in continuous flow. ' '=============================================================================== ======================== Dim fName Dim fso Dim WshShell ' First Delete the file c:\test.JPG (if it exists); since that is the file in ' which the screen is being captured. fName = "C:\test.JPG" Set fso = Wscript.CreateObject("Scripting.FilesystemObject") if fso.FileExists(fname) Then fso.DeleteFile (fname) fname="" set fso = nothing end if WScript.Sleep 1000 'This time allows the CPU to reset t o normal time levels with respect to the shell. Set oWordBasic = CreateObject("Word.Basic") 'This is needed since we cannot use sendkeys directly from shell to another app oWordBasic.SendKeys "{prtsc}" oWordBasic.AppClose "Microsoft Word" Set oWordBasic = Nothing WScript.Sleep 700 'Opening Paint Application set WshShell = CreateObject("WScript.Shell") WshShell.Run "C:\winnt\system32\mspaint.exe" 'WshShell.Run "mspaint" WScript.Sleep 1000 'Sleep time for Paint to reactivate when loaded. 'CUrrent screen is being captured.

wshshell.sendkeys "%{TAB}" 'Force Tab over to Paint window & see what is being c aptured. 'Activating Paint Application WshShell.AppActivate "untitled - Paint" WScript.Sleep 1500 WshShell.SendKeys "^v" WScript.Sleep 1200 'Save Screenshot WshShell.SendKeys "^s" WScript.Sleep 500 WshShell.SendKeys "c:\test.JPG" WScript.Sleep 500 WshShell.SendKeys "{TAB}" WshShell.SendKeys "j" WshShell.SendKeys "+{TAB}" WshShell.SendKeys "{ENTER}" WScript.Sleep 1550 WshShell.SendKeys "%fx" 'Release ObjectsSet set WshShell = Nothing WScript.Quit 'COmplete exit done 'Exiting out of the file & mspaint 'File is saved as c:\test.JPG 'Clipboard is captured.

'**************************************************

Das könnte Ihnen auch gefallen