473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to read text from the interface of another application?

Hi,

I want to write a C# windows application that reads some text from the
interface of another (separate) application, and am looking for a few ideas
as to where to start.

Specifically, I would appreciate some help with the following questions:
1) What is the best way to determine how the information I want is held in
the other application?
2) What will probably be the best way to access the information I want.

For question 1, I suspect that the information I want it is in the
equivalent of a label control, but am not sure. It could be a graphic object
of some sort...

For question 2, I am guessing that I will need to use some Win 32 APIs to
get a handle to the window I want, and then perhaps start capturing messages
on it? (That of course assumes that the text I want to capture is neatly
displayed in an object that can be accessed via its handle, however that
might not be the case!)

Thanks in advance.
Nov 17 '05 #1
2 7889
Andy wrote:
I want to write a C# windows application that reads some text from the
interface of another (separate) application, and am looking for a few
ideas as to where to start.

Specifically, I would appreciate some help with the following questions:
1) What is the best way to determine how the information I want is held in
the other application?
2) What will probably be the best way to access the information I want.

For question 1, I suspect that the information I want it is in the
equivalent of a label control, but am not sure. It could be a graphic
object of some sort...
Well, you can do the simple manual checks. Like, can you select the text
with the mouse? If you change the default font in your Windows settings,
does the font change in the control? Get Winspector
(http://www.windows-spy.com/) and see if you can detect anything
interesting about the control.
For question 2, I am guessing that I will need to use some Win 32 APIs to
get a handle to the window I want, and then perhaps start capturing
messages on it? (That of course assumes that the text I want to capture is
neatly displayed in an object that can be accessed via its handle, however
that might not be the case!)


Right. Or you could use GetWindowInfo to query information about the
control. Or you could send a WM_GETTEXT message to the control
(http://shrinkster.com/87j) to read the window text directly. But this
will all only work if the control really has a handle and stores its text
in the "Windows standard" way.

Otherwise, if the text is really graphics, you'll have to use some form of
OCR - come to think of it, AutomatedQA's next version of TestComplete is
supposed to be able to do this: http://shrinkster.com/87k I don't think
you'll be able to use that from your app directly because it will be part
of their tool, but maybe it can give you a few ideas.

Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Nov 17 '05 #2
Thanks very much Oliver - a very useful reply that should set me off in the
right direction.

I've used Spy++ before, but wasn't aware of Windows Spy. It looks good.

"Oliver Sturm" <ol****@sturmnet.org> wrote in message
news:xn****************@msnews.microsoft.com...
Andy wrote:
I want to write a C# windows application that reads some text from the
interface of another (separate) application, and am looking for a few
ideas as to where to start.

Specifically, I would appreciate some help with the following questions:
1) What is the best way to determine how the information I want is held in
the other application?
2) What will probably be the best way to access the information I want.

For question 1, I suspect that the information I want it is in the
equivalent of a label control, but am not sure. It could be a graphic
object of some sort...


Well, you can do the simple manual checks. Like, can you select the text
with the mouse? If you change the default font in your Windows settings,
does the font change in the control? Get Winspector
(http://www.windows-spy.com/) and see if you can detect anything
interesting about the control.
For question 2, I am guessing that I will need to use some Win 32 APIs to
get a handle to the window I want, and then perhaps start capturing
messages on it? (That of course assumes that the text I want to capture is
neatly displayed in an object that can be accessed via its handle, however
that might not be the case!)


Right. Or you could use GetWindowInfo to query information about the
control. Or you could send a WM_GETTEXT message to the control
(http://shrinkster.com/87j) to read the window text directly. But this
will all only work if the control really has a handle and stores its text
in the "Windows standard" way.

Otherwise, if the text is really graphics, you'll have to use some form of
OCR - come to think of it, AutomatedQA's next version of TestComplete is
supposed to be able to do this: http://shrinkster.com/87k I don't think
you'll be able to use that from your app directly because it will be part
of their tool, but maybe it can give you a few ideas.

Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: supportgeek | last post by:
Greetings. Would anyone know the right direction to point me on this one? I need to read text from a Windows Application based on cursor position. And enter text based on what is read. ...
2
by: Michael Winter | last post by:
Below is the IDL definition of the HTMLOptionElement. interface HTMLOptionElement : HTMLElement { readonly attribute HTMLFormElement form; attribute boolean defaultSelected;...
4
by: CrimeMaster | last post by:
HI I have an Exe file when it runs ,there are just two controls on the window.One is a ListBox and another is a Multi line Rich Edit control.When i click on an item in the list some text is...
4
by: Paul | last post by:
Hi everyone, I have created my first real life application, that runs in the system tray and monitors changes to the clipboard, then depending on the content it may search our stock file and...
15
by: Xah Lee | last post by:
On Java's Interface Xah Lee, 20050223 In Java the language, there's this a keyword “interface”. In a functional language, a function can be specified by its name and parameter specs....
3
by: Meitham | last post by:
Hi, I am trying to write a simple program that reads data from a source file (Excel sheet, XML file or text file) and then write the data into another application by pasting the data into the...
0
by: JosAH | last post by:
Greetings, welcome back; above we discussed the peripherals of the Library class: loading and saving such an instantiation of it, the BookMark interface and then some. This part of the article...
6
by: Steven Woody | last post by:
Hi, for example, i have unsigned char buff the buffer hold a sequences of raw bytes. My question is, what is the standard method of reading the `buff' via std::istream interface? A...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.