[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Windows Automation

Marc Ch

3/24/2009 2:39:00 AM

So, I'm trying to figure out how to automate various programs using
ruby, and feeling a bit over my head at the moment. I'm still pretty
new to ruby and programming, so maybe this is beyond me, but its the #1
reason I decided to learn ruby in the first place.

What I'm wondering is...where to start? I believe I'm right in the fact
that I need to be using WIN32OLE, but beyond that I can't seem to get
anywhere.

How do you determine what the exact name of the program is that you need
to pass as a parameter when creating a new WIN32OLE
object('WhatProgramNameHere.Application')? How do you find what methods
can be used with that specific program? Am I even right in assuming I
should be using WIN32OLE? If someone would be so kind as to steer me in
the right direction with some tips or reading material I'd be eternally
grateful. :)

Thanks for reading,
Marc
--
Posted via http://www.ruby-....

6 Answers

Charles Calvert

3/24/2009 10:16:00 PM

0

On Mon, 23 Mar 2009 21:38:54 -0500, Marc Ch <wooingruby@gmail.com>
wrote in <cf299a71d3bf68781fe420e8b308759a@ruby-forum.com>:

[snip]

>How do you determine what the exact name of the program is that you need
>to pass as a parameter when creating a new WIN32OLE
>object('WhatProgramNameHere.Application')? How do you find what methods
>can be used with that specific program? Am I even right in assuming I
>should be using WIN32OLE?

I don't know if there are any alternatives, but for automation on
Windows, OLE is the way to go.

As for information, you're looking for OLE interface documentation. If
you want it for Microsoft applications, then look at the MSDN
documentation at <http://msdn.microsof.... For example, if you
wanted to automate Outlook 2007, you would look at
<http://msdn.microsoft.com/en-us/library/bb17661.... Note that
when you search for said documentation on MSDN, use the search phrase
"FOO object model" where FOO is the name of the application.

If you're trying to automate a nonMS application, then you'll need to
check the documentation for the application.

If you didn't know, you can only automate applications with OLE if
they expose an OLE interface. Those that don't may support DDE
(http://en.wikipedia.org/wiki/Dynamic_Dat...).

--
Charles Calvert | Web-site Design/Development
Celtic Wolf, Inc. | Software Design/Development
http://www.celti... | Data Conversion
(703) 580-0210 | Project Management

David Mullet

3/25/2009 1:29:00 AM

0

Marc Ch wrote:
> So, I'm trying to figure out how to automate various programs using
> ruby, and feeling a bit over my head at the moment. I'm still pretty
> new to ruby and programming, so maybe this is beyond me, but its the #1
> reason I decided to learn ruby in the first place.
>
> What I'm wondering is...where to start? I believe I'm right in the fact
> that I need to be using WIN32OLE, but beyond that I can't seem to get
> anywhere.
>
> How do you determine what the exact name of the program is that you need
> to pass as a parameter when creating a new WIN32OLE
> object('WhatProgramNameHere.Application')? How do you find what methods
> can be used with that specific program? Am I even right in assuming I
> should be using WIN32OLE? If someone would be so kind as to steer me in
> the right direction with some tips or reading material I'd be eternally
> grateful. :)
>
> Thanks for reading,
> Marc

In addition to Charles' recommendations, you'll find a lot regarding
Windows automation on my "Ruby on Windows" blog:

http://rubyonwindows.bl...

David

--
Posted via http://www.ruby-....

Marc Ch

3/26/2009 9:21:00 PM

0

Thanks for the replies; very useful stuff. Maybe I'm blind, but I've
been crawling through the MSDN documentation for help with iexpress, and
I can't seem to figure out what its object is called. The best I can
find is a list of what command line switches/options it supports
(http://technet.microsoft.com/en-us/library/bb4...).

I've tried just guessing a large variety of obvious names for it as
well, but that doesn't seem to do anything but make me want to slam my
face against a rock. ;) If I'm completely overlooking it, can someone
point it out for me?

I did find, thanks to David's blog, that I can start it up without OLE
using system('iexpress') but I haven't yet been able to succesfully make
use of the defined command line options with that.

Not sure which way is best, but if anyone can help out with either/both
that'd be awesome.

Thanks,
Marc
--
Posted via http://www.ruby-....

Charles Calvert

5/23/2009 2:46:00 PM

0

On Thu, 26 Mar 2009 16:20:39 -0500, Marc Ch <wooingruby@gmail.com>
wrote in <71558ab1e7dee6bafba69ea693749fc0@ruby-forum.com>:

>Thanks for the replies; very useful stuff. Maybe I'm blind, but I've
>been crawling through the MSDN documentation for help with iexpress, and
>I can't seem to figure out what its object is called. The best I can
>find is a list of what command line switches/options it supports
>(http://technet.microsoft.com/en-us/library/bb4...).

I suspect that it doesn't expose and OLE interface. Many of
Microsoft's applications don't. Building such an interface is time
consuming and costly, and I doubt they'd bother for something like
that.

Googling didn't turn up anything, so I suspect that you're out of
luck.

--
Charles Calvert | Web-site Design/Development
Celtic Wolf, Inc. | Software Design/Development
http://www.celti... | Data Conversion
(703) 580-0210 | Project Management

Caleb Clausen

5/23/2009 4:07:00 PM

0

On 3/26/09, Marc Ch <wooingruby@gmail.com> wrote:
> I did find, thanks to David's blog, that I can start it up without OLE
> using system('iexpress') but I haven't yet been able to succesfully make
> use of the defined command line options with that.

Kernel#system works the same on windows and unix. Command line options
are given after the name of the program you want to run, separated by
a space. So, to start iexpress in quiet mode, try system('iexpress
/Q'). Alternately, you can pass each option in a separate string:
system('iexpress','/Q','/R:A') starts it in quiet mode and forces a
restart when iexpress exits.

Bosko Ivanisevic

5/23/2009 4:38:00 PM

0

On May 23, 4:45 pm, Charles Calvert <cb...@yahoo.com> wrote:
> On Thu, 26 Mar 2009 16:20:39 -0500, Marc Ch <wooingr...@gmail.com>
> wrote in <71558ab1e7dee6bafba69ea693749...@ruby-forum.com>:
>
> >Thanks for the replies; very useful stuff.  Maybe I'm blind, but I've
> >been crawling through the MSDN documentation for help with iexpress, and
> >I can't seem to figure out what its object is called.  The best I can
> >find is a list of what command line switches/options it supports
> >(http://technet.microsoft.com/en-us/library/bb4...).
>
> I suspect that it doesn't expose and OLE interface.  Many of
> Microsoft's applications don't.  Building such an interface is time
> consuming and costly, and I doubt they'd bother for something like
> that.
>
> Googling didn't turn up anything, so I suspect that you're out of
> luck.
>
I also doubt iexpress has OLE interface. Anyway if you are interested
in using Ruby for automation on Windows you can read my article about
MS Office automation I recently had to deal with on
http://pragmaticdevnotes.wordpress.com/2008/12/17/with-a-little-help-....
Unfortunately I forgot to list some tools that can be useful for such
a tasks and the main one is:

http://homepage1.nifty.com/markey/ruby/win32ole/soleb-...

With it you can browse all OLE objects registered on your system, see
their methods, properties and some other things. You should start it
and check whether iexpress has registered some OLE interfaces at all.
Besides you can examine code and see how you can get information about
OLE methods and their arguments, OLE properties, etc.

Regards,
Boško Ivaniševic