Kash Posted May 5, 2009 Posted May 5, 2009 Hello, I am trying to do screen capture and save it to word file. below is my code. $FileName = @ScriptDir & @UserName & ".doc" $oWordApp = _WordCreate ( $FileName ,"",0,0) $oDoc = _WordDocGetCollection ($oWordApp, 0) _ScreenCapture_Capture($FileName) Sleep(5000) _WordDocSave ($oDoc) _WordQuit ($oWordApp) This code successfully creates a file, but NO screen shot is saved in the file. Can someone help me here?
martin Posted May 5, 2009 Posted May 5, 2009 Hello,I am trying to do screen capture and save it to word file. below is my code. $FileName = @ScriptDir & @UserName & ".doc"$oWordApp = _WordCreate ( $FileName ,"",0,0)$oDoc = _WordDocGetCollection ($oWordApp, 0) _ScreenCapture_Capture($FileName)Sleep(5000) _WordDocSave ($oDoc) _WordQuit ($oWordApp)This code successfully creates a file, but NO screen shot is saved in the file. Can someone help me here?You can't save the file as a doc file. It must have an extension of bmp or jpg or tiff. (You can see this if you read the function code in ScreenCapture.au3 but it doesn't tell you in the help file.) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Kash Posted May 5, 2009 Author Posted May 5, 2009 You can't save the file as a doc file. It must have an extension of bmp or jpg or tiff. (You can see this if you read the function code in ScreenCapture.au3 but it doesn't tell you in the help file.)OK thanks...that was helpful.But is there any way to save it directly in .doc file..I have found alternate way of doing this. Use Insert Picture command of word to insert saved picture in the file. It works fine however while inserting a document it activates word file and then inert picture into it. I do not want that. I want to save picture in word file in the back ground.below is my code. Screen printing in Word document should NOT be visible to user. can you help please.$FileName = @ScriptDir & @UserName & ".doc"$oWordApp = _WordCreate ( $FileName ,"",0,0)_ScreenCapture_Capture( @ScriptDir & "test.gif")$oDoc = _WordDocOpen ($oWordApp, $FileName)Send ("{ALT}")Send ("I")Sleep(500)Send ("P")Send ("F")WinWaitActive ("Insert Picture","",3)Send (@ScriptDir & "test.gif");press enter to insert the fileSend ("{ENTER}");press enter to go to next lineSend ("{ENTER}")_WordDocSave ($oDoc)
Valuater Posted May 5, 2009 Posted May 5, 2009 Use this to "Test" your location MsgBox(4096, "", @ScriptDir & @UserName & ".doc") 8)
Kash Posted May 5, 2009 Author Posted May 5, 2009 Use this to "Test" your locationMsgBox(4096, "", @ScriptDir & @UserName & ".doc")8)Location is fine...That is not a problem...Are you trying to suggest something?
Valuater Posted May 5, 2009 Posted May 5, 2009 Location is fine...That is not a problem...Are you trying to suggest something?Yes... look again!8)
Kash Posted May 5, 2009 Author Posted May 5, 2009 Yes... look again!8)Sorry...I have been up since last 12 hours....Can you please explain...? I am not getting what you are trying to tell me.....
Valuater Posted May 5, 2009 Posted May 5, 2009 Sorry...I have been up since last 12 hours....Can you please explain...? I am not getting what you are trying to tell me.....This...MsgBox(4096, "", @ScriptDir & @UserName & ".doc")Should be this.....MsgBox(4096, "", @ScriptDir & "\" & @UserName & ".doc")8)
Kash Posted May 5, 2009 Author Posted May 5, 2009 This...MsgBox(4096, "", @ScriptDir & @UserName & ".doc")Should be this.....MsgBox(4096, "", @ScriptDir & "\" & @UserName & ".doc")8)Yes but unfortunately it is not addressing my concern of adding picture in word document without activating it...
Andy007 Posted July 4, 2009 Posted July 4, 2009 Hi Kash, I add bmp files into word docs using the following: ... $bmp = _WordDocAddPicture ($oDoc, $my_bmp_filename, 0, 1) If Not @error Then $bmp.Range.InsertAfter (@CRLF & @CRLF) ... Regards,Andy (no, the other one)
lansti Posted July 6, 2009 Posted July 6, 2009 (edited) Why do you want to put the screen capture into a word document? I got a version where i get them as an attachements to an e-mail, but for this you'll need a smtp server.. Edited July 6, 2009 by lansti
DavidKarner Posted October 1, 2009 Posted October 1, 2009 You do not need to use the ScreenCapture function to do this as it is designed to create a file. Simply use a SEND command to send PrtSc to the system which windows will then copy the screen image to the clipboard. Then after you open your word document, just paste it with a Ctrl-V. Send("^v")
ValeryVal Posted October 2, 2009 Posted October 2, 2009 But screen can be with menu opened. This short and easy SimpleScreenCapture.au3: #include <ScreenCapture.au3> Global $count = 1 ; Key $ - to capture screen HotKeySet("$", "CaptureScreen") ; Key {ESC} - to quit script HotKeySet("{ESC}", "Terminate") while 1 Sleep(100) wEnd func CaptureScreen() _ScreenCapture_Capture( @ScriptDir & "\screen_" & $count & ".gif") $count += 1 endfunc func Terminate() Exit 0 endfunc allows to shot screen with menu opened. 1. Start script 2. Make screen view - step 1. 3. Press $ 4. Make screen view - step 2. 5. Press $ ....... Press {ESC}. After doing this script directory will have photos of your steps. The point of world view
JRowe Posted October 2, 2009 Posted October 2, 2009 Alright, back to the basics. Kash, what are you trying to do? We know you want to put a screenshot in a doc, but why? Maybe we can help you achieve your task without resorting to such a seemingly odd/obscure method. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now