From: Kyle Schmitt Date: 2008-02-28T01:53:41+09:00 Subject: Re: ruby screenshot? 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 :) #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 9:59 AM, aidy wrote: > 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 > >