MS Windows automation - howto use it?

Dear Ruby experts,

I would like to use Ruby's WIN32OLE and/or WIN32API capability to
automate a translation application.
In the documentation on the web, there are examples on how to
use Ruby to create Excel and Word documents and to write to them.

My problem is now that I do not know how to tell Ruby what to substitute in
the book example's lines

ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome

so that my application is loaded ( is it always NameoftheProgram.Application
?)
and what methods are then available to that object. I need to pass text into
a field, for instance ....

Thank you for your help!

Best regards,

Axel

<Nuralanur@aol.com> asked:

I would like to use Ruby's WIN32OLE and/or WIN32API capability to
automate a translation application.
In the documentation on the web, there are examples on how to
use Ruby to create Excel and Word documents and to write to them.

My problem is now that I do not know how to tell Ruby what to substitute in
the book example's lines

ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome

so that my application is loaded ( is it always NameoftheProgram.Application
?)
and what methods are then available to that object. I need to pass text into
a field, for instance ....

Martin Kahlert asked a similar question a few weeks ago, in the thread "Windows automation":
http://rubyurl.com/pklBm [1]

Depending on what you want to do, you may find an answer there (there are about 3 suggestions in that thread, the worst of which is mine, I believe :). Otherwise, check out Watir [2] and I'm sure there's at least one more project in the RAA [1] that can help you with what you're trying to do.

Now, I'll try and answer your direct questions with some explanation of stuff you don't seem to understand.
"InternetExplorer.Application" is known in Windows as a "program id". Others might include "Excel.Application", "Word.Application", "Scripting.Regexp", "Scripting.FileSystemObject" (but why would you use either of these latter from Ruby?)
I am pretty sure you can substitute a program id in the WIN32OLE constructor with a class id, which looks more like "{6BF52A52-394A-11D3-B153-00C04F79FAA6}" (Flash object). It's just a different way to specify what OLE object to create.

How do you know what methods your new Flash object has? That's tricky - you can't just use my_ole_object.methods, because it doesn't actually have any special ones - it uses method_missing. You need to check the documentation for the OLE object itself. When I'm developing using Word and Excel automation, I usually develop that code in Word and Excel (record macros, use the help and the object browser to help figure out how to do whatever I need to do) and then just translate that to Ruby (it's pretty straightforward).

Cheers,
Dave

[1] http://groups.google.com.au/groups?hl=en&lr=&safe=off&threadm=YBFVd.182663%24K7.21911%40news-server.bigpond.net.au&rnum=1&prev=/groups%3Fq%3Dmartin%2Bkahlert%2Bwindows%2Bautomation%26hl%3Den%26btnG%3DGoogle%2BSearch

[2] http://wtr.rubyforge.org/

ยทยทยท

----- Original Message -----

How do you know what methods your new Flash object has? That's tricky - you can't just use my_ole_object.methods, because it doesn't actually have any special ones - it uses method_missing.

Minor note: You could probably use the #ole_methods method to get a
(partial) list of known methods. Doesn't give you any information on
method arguments though which is why you would probably need the
documentation anyway.

Cheers,
Thomas.