Jump to content

Recommended Posts

Posted

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?

Posted

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.
Posted

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 file

Send ("{ENTER}")

;press enter to go to next line

Send ("{ENTER}")

_WordDocSave ($oDoc)

Posted

Use this to "Test" your location

MsgBox(4096, "", @ScriptDir & @UserName & ".doc")

8)

Location is fine...That is not a problem...

Are you trying to suggest something?

Posted

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.....

Posted

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)

NEWHeader1.png

Posted

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...

  • 1 month later...
Posted

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)

Posted (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 by lansti
  • 2 months later...
Posted

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")

Posted

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

Posted

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. :)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...