Re: interacting with another program

To summarize:

  1. Read data from another program by ruby program
  2. Data analysis by ruby program
  3. action perform in the other program by ruby program

As far as I understand you want to interact with Win32 GUI application.
Try to use Windows messages to get data and perform actions on its GUI
controls (text area, buttons).

All you need is:

  1. Find the program window (== get it’s handle) by title
  2. Find the GUI control you want to work with (== get it’s handle)
  3. Send message to this control (for example - to get text from text box
    you need something like WM_GETTEXT message (see MSDN for details), to
    push a button WM_LBUTTONDOWN,…)

For step 1, 2 I cannot remember Win API functions by name, but you
shouldn’t have any problems finding one (See MSDN, section about Window
functions).

It’s very brief explanation. If you have more specific question - feel
free to ask.

If you use Windows as an OS to perform the interaction
with another program, you might have a look at AutoIt and how to use
it from Ruby:

Best regards,

Axel

Alexey K. wrote:

All you need is:

  1. Find the program window (== get it’s handle) by title
  2. Find the GUI control you want to work with (== get it’s handle)
  3. Send message to this control (for example - to get text from text box
    you need something like WM_GETTEXT message (see MSDN for details), to
    push a button WM_LBUTTONDOWN,…)

For step 1, 2 I cannot remember Win API functions by name, but you
shouldn’t have any problems finding one (See MSDN, section about Window
functions).

It’s very brief explanation. If you have more specific question - feel
free to ask.

This should be the function to find the window handle:

For this I also need the name of the class, but I have installed a tool
that can show me that.

I couldn’t find a function on MSDN to find a controls handle, so I’m
kinda stuck on this one. Please help me out here.

To push a button I’ll need
BM_CLICK(BM_CLICK message (Winuser.h) - Win32 apps | Microsoft Learn)?

For textfield i want to get the text from, I think I have to use
EM_GETTEXTEX (EM_GETTEXTEX message (Richedit.h) - Win32 apps | Microsoft Learn)
right?

Jeppe J. wrote:

To push a button I’ll need
BM_CLICK(BM_CLICK message (Winuser.h) - Win32 apps | Microsoft Learn)?

For textfield i want to get the text from, I think I have to use
EM_GETTEXTEX (EM_GETTEXTEX message (Richedit.h) - Win32 apps | Microsoft Learn)
right?

I believe this should solve most of your problems.
http://raa.ruby-lang.org/project/win32-guitest/
Hope it helps.
Regards,
Manish

Manish S. wrote:

Jeppe J. wrote:

To push a button I’ll need
BM_CLICK(BM_CLICK message (Winuser.h) - Win32 apps | Microsoft Learn)?

For textfield i want to get the text from, I think I have to use
EM_GETTEXTEX (EM_GETTEXTEX message (Richedit.h) - Win32 apps | Microsoft Learn)
right?

I believe this should solve most of your problems.
http://raa.ruby-lang.org/project/win32-guitest/
Hope it helps.
Regards,
Manish

Thanks

I’ve actually looked a bit into autoit for ruby and it solved most of my
problems, but maybe this will come in handy if I have any trouble with
autoit.

My biggest problem right now is that the program I want to automate is
using some web based elements, which means that there is some text I
cant seem to get from the program. I’m considering using some kind of
screenscrape to regonize the text I need, if such solution is available
(or even nessecary).