Click to See Complete Forum and Search --> : Reading values from running application


jiltd
November 13th, 2007, 05:48 AM
Hello.

I have a running application "A" with some fields in it's window. (Windows XP platform)

Is it possible (using WinAPI or something else) to create a 2nd application which can read entered values from fields in the application "A".

I know this sounds a bit crazy, but i have to investigate this problem at work and don't know where to start.

P.S.: I am aware that this problem may be impossible to solve.

JVene
November 13th, 2007, 07:30 AM
There are several possible methods.

Look into DDE and OLE (older concepts that still work), ActiveX (which is a somewhat more modern version of the other two) - all involve the exchange of data between applications.

There's also shared memory access using memory mapped files (conceptually simpler than the first three).

There are other approaches. The problem is usually solved by having the source program 'expose' it's data in some interface (that's where ActiveX or OLE comes in), such that other programs may access it.

If, however, you're trying to get to information in an application you aren't writing (and have no source to), then you may be left with a dubious but sometimes workable method involving messages. You can 'walk' the hierarchy of child windows in any application. You basically start with the desktop, wind your way through IT'S child windows (which are the application's main windows), then, when the application is found, walk through IT'S children until you find the controls. Then, you can use standard messages to ask for the text content of those controls - but it's tricky.

ahoodin
November 13th, 2007, 08:13 AM
Try using FindWindow() and pWnd->SetWindowText("What I want to say");.

HTH,