Ruby screenshot?

Is there any way I an take a screenshot and paste it to Word through
Ruby. Here is hwat I have got.

require ‘win32ole’

word = WIN32OLE.new(‘Word.Application’)
#word.Visible = true
document = word.Documents.Open(‘c:\Screenshot.doc’)
autoit = WIN32OLE.new(“AutoItX3.Control”)
autoit.Send"{PRINTSCREEN}"
… what goes here
document.Close
word.Application.Quit

Cheers

Aidy

On Feb 27, 11:53 am, “Kyle S.” [email protected] wrote:

It’s been so long since I’ve done this, I realized I forgot, and it
got to me, so I just played with it for a few minutes to refresh my
memory. It helps if you’ve had the unfortunate experience of having
scripted word before using {vb|j}script.
Sadly the ruby docs and webpages, as helpful as they are, don’t give
you a good feeling for the word ole object(s). Dig up the docs for
scripting word from a more native microsoft scripting language.

Save yourself some pain:

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

Regards,

Dan

It’s been so long since I’ve done this, I realized I forgot, and it
got to me, so I just played with it for a few minutes to refresh my
memory. It helps if you’ve had the unfortunate experience of having
scripted word before using {vb|j}script.
Sadly the ruby docs and webpages, as helpful as they are, don’t give
you a good feeling for the word ole object(s). Dig up the docs for
scripting word from a more native microsoft scripting language.

require ‘irb/completion’
#unfortunately this doesn’t add completion for ole methods, but hey,
it’s nice to have…

require ‘win32ole’
word=WIN32OLE.new(‘Word.Application’)
#Very important, so you can see what you’re doing :slight_smile:
#if you forget to do this, and ruby seems stuck/hung,
#word is probably displaying some sort of dialog (like save)
#and needs input. If that happens, open up another cmd
#and run…
#ruby -e “require
‘win32ole’;WIN32OLE.connect(‘Word.Application’).visible=true”
word.visible=true
word.Documents.Add()
word.Selection.Paste
word.ActiveDocument.SaveAs(‘C:\Test.doc’)
word.ActiveDocument.close
word.Quit

Good luck
–Kyle

On Wed, Feb 27, 2008 at 3:12 PM, Daniel B. [email protected]
wrote:

Save yourself some pain:

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

Regards,

Dan

Hey, not a bad little lib.
Still, I don’t know if it would have solved his issue.
Apparently the ruby-win32ole bridge in 1.9 is better, so maybe it’ll
be less nightmareish to explore OLE in. Today was the first time I
used ruby in windows for maybe 4 months.

I like that.

–Kyle