Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you read values from an open application in Windows?

I want to create a program or use a program that will read the memory values out of another application. Does anyone know of an application/library that will do this?

The target app is this. I would like to read the exchange rate values from it.

I'm an experienced c# programmer, but have never worked with the Win32/user32 api which is what I'm assuming I'll have to deal with to pull this off.

Any help that gets me going in the right direction is greatly appreciated.

Update: I managed to use Spy++ to get the window handle, so I'm sure I can get the values some how.

like image 709
Arron S Avatar asked Aug 03 '09 04:08

Arron S


2 Answers

Have you looked into AutoIT or AutoHotKey? Both of these open source options have well documented abilities to read text from application windows (and send keystrokes or mouseclicks to them).

AutoIT is very easy to use and well documented. An example of reading text from a window would be:

$text = WinGetText("title of window", "")
MsgBox(0, "Text read was:", $text)

This can be compiled into an executable.

like image 64
Michael Galos Avatar answered Oct 17 '22 19:10

Michael Galos


Typically an application creates controls in a dialog in a consistent manor, same ID, same order etc, so finding a control programatically is fairly simple. Using Spy++ find the control's ID and then you can search the windows created by the application for the desired control. Not being familiar with the app in question I cannot give specifics, but if Spy++ shows the value you desire, it is likely not difficult to obtain the value in your code.

What type of control is the value displayed in? You'll may be able to use GetDlgItemText to obtain the value once you have the parent window handle and control ID? To get the parent window try using EnumWindows.

like image 2
Stephen Nutt Avatar answered Oct 17 '22 21:10

Stephen Nutt