Web App with Windows GUI

M

Mike Stephens

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=E2=80=99m 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=E2=80=99m not sure how I wo=
uld
pass data to and from it.

How do people normally do this kind of thing?

-- =

Posted via http://www.ruby-forum.com/.=
 
R

Rajinder Yadav

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=92m 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=92m 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.


--=20
Kind Regards,
Rajinder Yadav | 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
 
C

Charles Calvert

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]
 
J

John W Higgins

[Note: parts of this message were removed to make it a legal post.]

Afternoon

Charles Calvert wrote in post #957599:

Wow!

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

Pity - it seemed such a nice idea...

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
 
C

Charles Calvert

[Note: parts of this message were removed to make it a legal post.]

Afternoon

Charles Calvert wrote in post #957599:

Wow!

I hope that was a good "wow". :)

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.
 
M

Mike Stephens

Charles Calvert 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
 
E

Eric Christopherson

Charles Calvert wrote in post #957671:

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).
 
C

Charles Calvert

Charles Calvert wrote in post #957671:

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top