Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Print Screen in VBScript

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,53752
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Print Screen in VBScript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Print Screen in VBScript - 11/23/2007 12:14:27 AM   
  rasaec


Posts: 5
Score: 0
Joined: 11/22/2007
Status: offline
Hi,

My aim is to Print the Screen in VBScript and to paste it in a word document.

I can capture the screens using wordbasic in VBScript. My question is how to paste this screenshots using VBScript into the desired document. Please provide some inputs if any....



_____________________________

cZr
 
 
Post #: 1
 
 RE: Print Screen in VBScript - 11/23/2007 10:54:57 AM   
  dm_4ever


Posts: 2726
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Do a search for Word.Application...this link may also help...

http://www.microsoft.com/technet/scriptcenter/resources/officetips/archive.mspx

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to rasaec)
 
 
Post #: 2
 
 RE: Print Screen in VBScript - 11/25/2007 5:01:29 PM   
  rasaec


Posts: 5
Score: 0
Joined: 11/22/2007
Status: offline
Hi,

Thanks for your comments...

I am new to VBScript. Any way I search all the commands in google and use it for my logic to Automate my application.

The Script process is as follows:
1. Open an application
2. Before run, I want to take Screen Shots and paste it in a new document
3. Run the application
4. After run, I want to take Screen Shots and paste it in the same document

I can take screen shots (for step 2 and 4) using VBScript. I donk know how to paste the Screens for step 2 and use the same for step 4

I tried using word.application to open a document. Kindly provide some input(Script) if any......

Thanks and Regards

cZr

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Print Screen in VBScript - 11/25/2007 9:53:22 PM   
  morpheus83uk

 

Posts: 435
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

If you provide us with what you have so far we can work with you from there...

Thanks

James

(in reply to rasaec)
 
 
Post #: 4
 
 RE: Print Screen in VBScript - 11/25/2007 10:21:45 PM   
  rasaec


Posts: 5
Score: 0
Joined: 11/22/2007
Status: offline
 
Please Check the code and provide your comments....

Dim WB
Dim WshShell
Set WB = CreateObject("Word.Basic")
Set WshShell = CreateObject("WScript.Shell")

 
'Before run---Some application process'
 
WB.SendKeys "{prtsc}"

'Here I need a code for opening a new word document and pasting the screenshots into it'

'After run--Some application process'
 
WB.SendKeys "{prtsc}"
 
'Another Code for pasting the Screenshots in the same document (Append) and to save it in the given folder'
 
 
Thanks
cZr
 
 
 

(in reply to morpheus83uk)
 
 
Post #: 5
 
 RE: Print Screen in VBScript - 11/26/2007 1:27:56 AM   
  morpheus83uk

 

Posts: 435
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

This should give you a starting block.


      

it will printscreen wait 5 seconds and then open up a word document for you.

What exactly is your full code and what are you properly trying to achive?

With this we may be able to assist further...

Many Thanks

James

(in reply to rasaec)
 
 
Post #: 6
 
 RE: Print Screen in VBScript - 11/26/2007 5:21:55 PM   
  rasaec


Posts: 5
Score: 0
Joined: 11/22/2007
Status: offline
Hello,

Thanks for your code.....

< Message edited by rasaec -- 11/27/2007 10:36:28 PM >

(in reply to morpheus83uk)
 
 
Post #: 7
 
 RE: Print Screen in VBScript - 11/2/2008 5:02:30 AM   
  jghand

 

Posts: 1
Score: 0
Joined: 11/2/2008
Status: offline
I am attempting a similar effort with the code below, but all I get is data currently on the clipboard instead of a screen print.

Set objShell = CreateObject("WScript.Shell")

  Set oWordApp = CreateObject("Word.Application")
  If oWordApp Is Nothing Then
     MsgBox "Couldn't start Word."
  Else
     Dim oWordApp
     Dim oWordDoc
     Dim oBMs

oWordApp.Visible = True

     ' Open a new document
     Set oDoc = oWordApp.Documents.Add

     ' Set a page setup object variable
     Set oPS = oDoc.PageSetup

     ' Reduce the margins to .5" (36 points)
     oPS.TopMargin = 36
     oPS.BottomMargin = 36
     oPS.LeftMargin = 36
     oPS.RightMargin = 36

objShell.Sendkeys "{prtsc}"
wscript.sleep 5000

     ' Paste in the screen shot
     oWordApp.Selection.Paste

     ' Center the screen shot
     onst wdAlignParagraphCenter = 1
     'oDoc.Paragraphs(1).Alignment = wdAlignParagraphCenter

oWordApp.DisplayAlerts = False
oWordApp.ActiveDocument.SaveAs "C:\temp\ScreenShot.doc",6

     ' Close and don't save changes to the document
     Const wdDoNotSaveChanges = 0
     oDoc.Close wdDoNotSaveChanges

     ' Close the Word instance
     oWordApp.Quit

     ' Clean up
     Set oPS = Nothing
     Set oDoc = Nothing
     Set oWordApp = Nothing
  End If

(in reply to rasaec)
 
 
Post #: 8
 
 RE: Print Screen in VBScript - 11/3/2008 3:04:19 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
Print Screen cannot be sent to an application through script (sendkeys).

_____________________________

Rischip
Author of - The Grim Linker

(in reply to jghand)
 
 
Post #: 9
 
 RE: Print Screen in VBScript - 11/3/2008 3:22:24 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
Look here http://www.visualbasicscript.com/m_49426/mpage_1/key_print%2cscreen/tm.htm#49493

Also there are ActiveX controls that can be downloaded which will allow you to do what you wish.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to Rischip)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Print Screen in VBScript Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts