如何在另一个程序中寻找 相应的text
上一篇 /
下一篇 2011-02-23 15:34:01
/ 个人分类:Common
Re: Scraping the text from another application with win32 api
Posted29
March 2009 - 05:04 PM
The problem is most likely that the window is using gdi to draw the text
in color, or some other proprietary text engine [non OS]. There are 4
ways that you can possibly get the text, i have implemented 2 of them
myself in other projects.
Option 1 [I had a fairly reliable code for this at one time, it took me
about an hour to get working]:
Screen shot screen scrape ... this is actually very simple, especially
if you know the font name and font size. You simply make the program
grab the screen [there is c# sample code for this using BitBlt], then
use GDI+ in c# to compile a lookup based off of a bitmap of each
character. This lookup shouldnt actually be a bitmap, but rather an
array of coordinates for the fonts drawing area for faster results.
Option 2 [I have created a c# packet sniffer with a built in c# compiler
for custom message handling(JIT scripting basically)] there are c#
implementations of packet sniffers, the chat text will most likely be
unencrypted, and you can simply sniff on the same port that the chat
program is running on.
Option 3: Use the clipboard ... simply select the window in code, and
invoke Ctrl-A then Ctrl-C, then get clipboard data from
Clipboard.GetText method.
Option 4: Hook into the api calls for GDI if in fact the program is
using gdi to do the text rendering, I have no idea how to do this, but
here is an article on it
http://www.codeproje...em/hooksys.aspxIf you have any questions email me at "bra**nt@on***e*c**sgu**y.**.com"
without the *'s
收藏
举报
TAG:
find
Find
text