p_mcp
p_mcp

Reputation: 2791

Read on-screen text from external app. API Hooking?

I have a Java background so have limited knowledge when it comes to C# and C++. Basically I am trying to "read" text from another application which is displayed on screen...

enter image description here

To be specific, I want to read the dealer chat message from Pokerstars... on the fly...

What is the best way to read this text into a Java program on the fly? Ive head about API hooking, is this the only way and how would I do this in Java?

Thanks Phil

Upvotes: 4

Views: 10621

Answers (2)

user223264
user223264

Reputation:

One way to do it, which works as long as text is not anti-aliased, like in your image:

From your application, take a screenshot of the other application's window. Search the screenshot for all non-white pixels. Make a list of all the non-white pixels. For each pair of non-white pixels in the list, if the pair touches each other, put them in the same "group." Do this until all the pixels are grouped together.

Then for each group, compare its shape to a table of predefined shapes. If the shape isn't in the table, ask the user to type the letter, then save the shape and which letter it is to the table.

Now you have ASCII codes for all the letters in the window.

This is not the cleanest way to scrape text from a window, but it is hard to defeat. For any move made by the other application to make the text harder to read by a computer, it will become harder to read by a human, which lowers the usefulness of the application.

Upvotes: 2

Angelom
Angelom

Reputation: 2531

If the application you want to hook into is c# then maybe reflector is a good place to start.

http://reflector.red-gate.com/download.aspx?TreatAsUpdate=1

Another thing you wany want to look into is reading the network traffic and grabbing the data at that level. In which case take a look at wireshark.

http://www.wireshark.org/

You may be able tgo create a proxy, where data is directed through your application at the network level and you pass it on but read out the interesting parts.

Good Luck.

Upvotes: 2

Related Questions