If groveling around in the low-level Windows API doesn't interest you,
Windows automation might---you can use Ruby as a client for Windows
Automation thanks to a Ruby extension called
WIN32OLE
, written by
Masaki Suketa.
The examples in this section are taken from those
provided in the
WIN32OLE
distribution.
Windows automation
allows an
automation controller (a client) to issue commands and queries against
an automation server, such as Microsoft Excel, Word, PowerPoint, and
so on.
You can execute a method of an automation server by calling a method
of the same name from a
WIN32OLE
object. For instance, you can
create a new
WIN32OLE
client that launches a fresh copy of
Internet Explorer and commands it to visit the home page.
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome
|
Methods that aren't known to
WIN32OLE
(such as
visible
or
gohome
) are passed on to the
WIN32OLE#invoke
method, which sends the
proper commands to the server. The
WIN32OLE
reference
beginning on page 505 describes the class in detail, but
we'll go over a few of its features here.