Web App with Windows GUI

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 need a continuously running Ruby program (the Manager) that holds
references to each GUI and maintains state information about which
session id is assigned to the GUI instance and what screen the GUI is
currently sitting on. This is to avoid starting up an instance for each
call, and navigating to the relevant screen unnecessarily.

What I’m thinking is when a web service call comes in I want the web
service to connect to the Manager which will then check whether one of
the GUIs is assigned to the session concerned and return a reference to
the correct GUI so the web service can script it (or perhaps start up
another instance if one is required).

I could communicate with the Manager by some polling mechanism. But then
again if I can use Win32API to connect to the GUI, I should be able
somehow to connect to the Manager, although I’m not sure how I would
pass data to and from it.

How do people normally do this kind of thing?

On Tue, Oct 26, 2010 at 3:20 AM, Mike S. [email protected]
wrote:

currently sitting on. This is to avoid starting up an instance for each
somehow to connect to the Manager, although Im not sure how I would
pass data to and from it.

How do people normally do this kind of thing?

you could look into using local sockets or PRC, not sure if there is a
gem to make this easier.


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

On Tue, 26 Oct 2010 02:20:19 -0500, Mike S. [email protected]
wrote in [email protected]:

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 C. wrote in post #957599:

If the application that you
want to drive doesn’t provide such an API, find one that does, or
write your own.

Wow!

It’s a vendor app. Thye can’t provide web services for maybe a year.

Pity - it seemed such a nice idea…

On Wed, 27 Oct 2010 16:36:03 -0500, John W Higgins [email protected]
wrote in
[email protected]:

Wow!

I hope that was a good “wow”. :slight_smile:

It’s a vendor app. Thye can’t provide web services for maybe a year.

Pity - it seemed such a nice idea…

I know. I thought the same thing when we finally realized that we
were getting nowhere.

If you are still curious then you should start with this
http://www.autoitscript.com/autoit3/index.shtml and see if AutoIt can manage
the application - if it cannot do so then you are really out of luck - if it
can - you have a huge hill but it would work in theory.

That’s an interesting suggestion. I suspect that you’ll run into the
same sorts of limitations, but you can probably do it a lot more
quickly and cheaply.

I do want to clarify one point about my earlier post. Obviously it’s
possible to script GUIs; people do it regularly and the existence of
this product and others like it is a testament to that. They work
reasonably well for simple tasks with a limited number of variables
where there’s some tolerance for failure. Automating software
installations is one example.

The problem comes in when you have to manage actual use of a more
sophisticated application, track its state, input data, read output
and deal with errors. The complexity skyrockets and the tolerance for
failure decreases, particularly if you’re farming it out as a web
service or something similar.

Mike, is there any chance that you could tell us what this application
does? Someone may be able to suggest an alternative that you could
automate directly from Ruby or indirectly via COM.

Charles C. wrote in post #957671:

Mike, is there any chance that you could tell us what this application
does? Someone may be able to suggest an alternative that you could
automate directly from Ruby or indirectly via COM.

Its a VB Health Insurance package. The application is to register, view
and update new hospitals and spec|alists, and to allow them to check
whether a patient has cover. So it’s just reading and writing data to
text boxes, dropdowns etc

There might be some mileage in using AutoHotKey with Ruby. There was a
thread that mentioned it recently that looked pretty interesting:

http://www.ruby-forum.com/topic/296632

What’s more, the AutoHotKey community is very active, so they might be
able to help further with what you’re trying to do:

http://www.autohotkey.com/forum/

Charles

Afternoon

On Wed, Oct 27, 2010 at 1:56 PM, Mike S. [email protected]
wrote:

If you are still curious then you should start with this
http://www.autoitscript.com/autoit3/index.shtml and see if AutoIt can
manage
the application - if it cannot do so then you are really out of luck -
if it
can - you have a huge hill but it would work in theory.

John

On Thu, 28 Oct 2010 01:32:58 -0500, Mike S. [email protected]
wrote in [email protected]:

Charles C. wrote in post #957671:

Mike, is there any chance that you could tell us what this application
does? Someone may be able to suggest an alternative that you could
automate directly from Ruby or indirectly via COM.

Its a VB Health Insurance package. The application is to register, view
and update new hospitals and spec|alists, and to allow them to check
whether a patient has cover. So it’s just reading and writing data to
text boxes, dropdowns etc

Sorry, but I think that this falls into the category of being overly
fragile. By “VB” do you mean Visual Basic? If so, how is it
retrieving the data? Is there a database or web service that it talks
to? It might be easier to reverse engineer that (assuming that you’re
legally allowed to do so, of course).

On Thu, Oct 28, 2010 at 1:32 AM, Mike S. [email protected]
wrote:

Charles C. wrote in post #957671:

Mike, is there any chance that you could tell us what this application
does? Someone may be able to suggest an alternative that you could
automate directly from Ruby or indirectly via COM.

Its a VB Health Insurance package. The application is to register, view
and update new hospitals and spec|alists, and to allow them to check
whether a patient has cover. So it’s just reading and writing data to
text boxes, dropdowns etc

I would be very cautious when automating that sort of program, or any
large program where you care a lot about the data. I’ve found that
AutoHotkey doesn’t always work exactly right, even if it works when I
step through each procedure manually. Whether that’s generally from
bugs in AutoHotkey or in the app being scripted, I don’t know
(although in one case I’m sure it was a bug in the underlying app that
a script just happened to uncover; in that app, I would get a SOAP
exception if I copied a certain field to the clipboard and immediately
after that clicked a certain button).

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs