On Tue, 26 Oct 2010 02:20:19 -0500, Mike Stephens <rubfor / recitel.net>
wrote in <562b2859da2461ee0be872560a074522 / ruby-forum.com>:

>I am trying to design an application that scripts a GUI to expose its
>functionality as a set of web services.
>
>Under Windows, I can start one or more instances of the GUI and then
>start a Ruby program which obtains a reference to one of the GUIs and
>scripts it using Win32API.

I've been down this road.  If it's a simple GUI and was written as a
native Win32 app with no cross-platform widget libraries or home-grown
weirdness, it might sort of work 80% of the time.  If it's anything
different (Tk, wx-windows, QT, etc.), then it likely won't work at
all.

You can enumerate the windows, hook them, send keystrokes and mouse
clicks all you want, but it's too fragile to work well.  When trying
to do this under Win2K, we discovered, for example, that mouse clicks
sent using JournalPlaybackProc were always sent to the window with the
focus, contrary to what the MSDN docs said.  The hWnd member of the
EVENTMSG structure was always ignored.  I don't know if this has been
fixed in more recent versions of Windows.

A colleague and I spent many hours over the course of 18 months or so
in 2000 - 2002 trying to do exactly what you're talking about.  We
learned the hooking and related APIs inside and out, wrote some
interesting code, became two of the top experts in the area on Usenet,
and utterly failed to craft a workable solution.

Bottom line: trying to drive a GUI is too fragile.  You'll waste your
time and drive yourself nuts.  You need a API of some sort, whether
it's COM, sockets, or something else.  If the application that you
want to drive doesn't provide such an API, find one that does, or
write your own.

[snip rest]

-- 
Charles Calvert
Moderator - alt.computer.consultants.moderated
Submission Address: accm / celticwolf.net
Contact Address: accm_mod / celticwolf.net