Jump to content

Screen Capture Help


 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...

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)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 2 months later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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