问题
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.
回答1:
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.
回答2:
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.
回答3:
It might be easier to scrape their data by automating a screenshot and then ocr process. If that's your goal.
Potentially relevant links:
- get-a-screenshot-of-a-specific-application
- ocr-with-the-tesseract-interface
回答4:
May be this article helps - http://msdn.microsoft.com/en-us/magazine/cc163617.aspx, but I think it's not universal and for your task is better to get access directly to Forex API/Web-Service or try to catch needed data on network.
回答5:
It is possible to screen-scrap things created with native windows controls; if that is the case, you should be able to see the controls using Spy++. But some times controls are implemented "by hand", and there is no way to screen-scrap them (e.g. some Java graphic toolkits play directly with the graphics, so everything day do is meaningless from the outside, or even some Office menus are implemented without using the menu control).
The Windows accessibility API is a possible way to screen-scrap the values; check if "Narrator", the screen reader that comes with windows, is able to read aloud your target application.
来源:https://stackoverflow.com/questions/1220690/how-can-you-read-values-from-an-open-application-in-windows