append screenshot to a file

62 views
Skip to first unread message

aidy lewis

unread,
Feb 27, 2008, 9:45:13 AM2/27/08
to watir-general

HI,

I an looking to paste a screenshot to a file, I can do this with autoit  < autoit.Send"{PRINTSCREEN}" />, but I am looking to append to a file?


Aidy

Nathandelane

unread,
Feb 28, 2008, 8:20:39 AM2/28/08
to Watir General
You now need some way to get the data out of the clipboard - Ruby has
minimal support for this right now on Windows. My advice is to find
some other way of saving the data. There are a couple of active
screenshot saving programs for Windows available for free. Like
possibly http://www.screenshot-utility.com/, though that's not one
I've used. I can't remember right this second which ones I've used,
when I get to work I can check on it and let you know better.

Nathan

aidy lewis

unread,
Feb 28, 2008, 9:19:57 AM2/28/08
to watir-...@googlegroups.com
Hi Nathan,

Used this, not sure of it's stability

require 'win32ole'
def take_a_screenshot
word=WIN32OLE.new('Word.Application')
autoit = WIN32OLE.new("AutoItX3.Control")
word.Documents.Add()
autoit.Send("{PRINTSCREEN}")
word.Selection.Paste
word.ActiveDocument.SaveAs('C:\screenshots.doc')
word.ActiveDocument.close
word.Quit
end

take_a_screenshot

Aidy

ps not tested, if it works I'll bang it on the wiki.

Nathan Lane

unread,
Feb 28, 2008, 10:31:10 AM2/28/08
to watir-...@googlegroups.com
That would work, except you're saving a whole document containing the picture.  Is that what you were asking about appending to?
--
Nathan Lane
Home, http://nathandelane.awardspace.com

aidy lewis

unread,
Feb 28, 2008, 10:45:26 AM2/28/08
to watir-...@googlegroups.com
On 28/02/2008, Nathan Lane <natham...@gmail.com> wrote:
> That would work, except you're saving a whole document containing the
> picture. Is that what you were asking about appending to?
>
>
Yes, that would be a problem. Would need to append.

Aidy

Devangkumar Naik

unread,
Feb 28, 2008, 11:09:18 AM2/28/08
to watir-...@googlegroups.com
How to Use a Template to Generate N Testcase
with Names like TestCase1, TestCase2, TestCase3 ... TestCaseN
??
Any help?

-Devang

Nathan Lane

unread,
Feb 28, 2008, 10:56:23 AM2/28/08
to watir-...@googlegroups.com
Alright, here's the key - word.Documents.Add("C:\screenshots.doc") - that opens the same file as before.  But note that "C:\screenshots.doc" == 'C:\creenshots.doc' - I think the \s is a reserved escape code for space or something.  That's what I experienced anyway.

Nathan

On Thu, Feb 28, 2008 at 7:19 AM, aidy lewis <aidy....@googlemail.com> wrote:

aidy lewis

unread,
Feb 28, 2008, 12:49:24 PM2/28/08
to watir-...@googlegroups.com
On 28/02/2008, Nathan Lane <natham...@gmail.com> wrote:
> Alright, here's the key - word.Documents.Add("C:\screenshots.doc") - that
> opens the same file as before. But note that "C:\screenshots.doc" ==
> 'C:\creenshots.doc' - I think the \s is a reserved escape code for space or
> something. That's what I experienced anyway.
>
> Nathan
>
You looked at this

http://rubyforge.org/projects/win32screenshot/

Aidy

Željko Filipin

unread,
Feb 29, 2008, 6:34:33 AM2/29/08
to watir-...@googlegroups.com
On Thu, Feb 28, 2008 at 5:09 PM, Devangkumar Naik <devan...@hotmail.com> wrote:
> How to Use a Template to Generate N Testcase
> with Names like TestCase1, TestCase2, TestCase3 ... TestCaseN

Hi Devang,

I did not understand what are you trying to do. And it has no connection to this thread. I suggest that you start another thread and explain in more detail what you need to do.

Željko
--
ZeljkoFilipin.com

aidy lewis

unread,
Feb 29, 2008, 8:28:03 AM2/29/08
to watir-...@googlegroups.com
On 28/02/2008, Nathan Lane <natham...@gmail.com> wrote:

<code>

require 'watir'
require 'win32ole'
@@word=WIN32OLE.new('Word.Application')
@@word.Documents.Add()
def take_a_screenshot(url)
@autoit = WIN32OLE.new("AutoItX3.Control")
browser = Watir::IE.new
browser.bring_to_front
browser.goto(url)
browser.maximize
@autoit.Send("{PRINTSCREEN}")
browser.close
@@word.Selection.Paste
@autoit.Send("{ENTER}")
end

def save_file
@@word.ActiveDocument.SaveAs('C:\screenshots.doc')
@@word.ActiveDocument.close
@@word.Quit
end


take_a_screenshot('http://www.fsf.org/')
take_a_screenshot('http://www.pcs.org.uk')
save_file


</code>

Should it smarten it up and put it on th Wiki?

Aidy

Nathan Lane

unread,
Feb 29, 2008, 8:38:43 AM2/29/08
to watir-...@googlegroups.com
That's pretty cool - actually I looked at this: http://www.inquiry.com/techtips/vfox_pro/10min/10min0600.asp

Nathan Lane

unread,
Feb 29, 2008, 8:39:20 AM2/29/08
to watir-...@googlegroups.com
I'd say definitely - put it on the wiki.

aidy lewis

unread,
Feb 29, 2008, 9:43:33 AM2/29/08
to watir-...@googlegroups.com
On 29/02/2008, Nathan Lane <natham...@gmail.com> wrote:
> I'd say definitely - put it on the wiki.
>

Given up trying to log ino there can someone else put it up?

Aidy

Željko Filipin

unread,
Feb 29, 2008, 9:45:32 AM2/29/08
to watir-...@googlegroups.com
On Fri, Feb 29, 2008 at 3:43 PM, aidy lewis <aidy....@googlemail.com> wrote:
> Given up trying to log ino there can someone else put it up?

Can not log in? Any error messages?

Željko

aidy lewis

unread,
Feb 29, 2008, 9:47:32 AM2/29/08
to watir-...@googlegroups.com

No. Try to re-regoster and no email.

Željko Filipin

unread,
Feb 29, 2008, 10:48:46 AM2/29/08
to watir-...@googlegroups.com
On Fri, Feb 29, 2008 at 3:47 PM, aidy lewis <aidy....@googlemail.com> wrote:
> Try to re-regoster and no email.

I have reset your password. You should receive e-mail. Let me know if you do not receive it.

Željko

marcog

unread,
Mar 2, 2008, 7:52:12 AM3/2/08
to Watir General
On Feb 28, 6:49 pm, "aidy lewis" <aidy.le...@googlemail.com> wrote:
> http://rubyforge.org/projects/win32screenshot/

I have this successfully working with Watir - using Win32Screenshot
and Imagemagick as described here:

http://blog.aslakhellesoy.com/2006/12/2/getting-screenshots-from-watir

MG

aidy lewis

unread,
Mar 2, 2008, 1:20:23 PM3/2/08
to watir-...@googlegroups.com
Thanks for feedback, i put the code on the faq. Not entirely happy
with it, but i suppose that is iterative development. I am sick of
putting more tools on my machine so that is why i did it this way.

--
Sent from Google Mail for mobile | mobile.google.com

Nathan Lane

unread,
Mar 3, 2008, 8:27:40 AM3/3/08
to watir-...@googlegroups.com
How did you get Imagemagik to compile in windows?

Charley Baker

unread,
Mar 3, 2008, 10:59:22 AM3/3/08
to watir-...@googlegroups.com
There are binary distributions of ImageMagick for windows:

http://www.imagemagick.org/script/binary-releases.php

-Charley

MarioRuiz

unread,
Apr 11, 2008, 8:59:38 AM4/11/08
to Watir General
But is possible to save a screenshot if the internet explorer is not
visible? I mean with the visible parameter equal to false.

aidy lewis

unread,
Apr 11, 2008, 9:13:54 AM4/11/08
to watir-...@googlegroups.com
On 11/04/2008, MarioRuiz <ma...@betware.com> wrote:
>
> But is possible to save a screenshot if the internet explorer is not
> visible? I mean with the visible parameter equal to false.
>
doubt it
Reply all
Reply to author
Forward
0 new messages