我怎样才能在不同的应用程序读取窗口,控件的数据? [英] How can I read data from controls on window in a different application?
问题描述
我必须写观察另一个应用程序,并从窗口中提取信息的应用程序。什么是从他们的控制访问其他应用程序的窗口和获取数据的最佳方法是什么?
I have to write an application that observes another application and extracts information from the window. What is the best way to access windows from other applications and get data from their controls?
推荐答案
您需要的P / Invoke的的 的FindWindow
和的 FindWindowEx
函数来获取句柄到其他应用程序的父窗口和子控件。
You'll need to P/Invoke the FindWindow
and FindWindowEx
functions to retrieve a handle to the other application's parent window and child controls.
然后你需要使用像 GetWindowText时
访问特定控件中的文本。
Then you will need to use something like GetWindowText
to access the text for a particular control.
访问 pinvoke.net 了解你需要从C#调用这些函数的定义。
Visit pinvoke.net for the definitions you'll need to call these functions from C#.
被警告,这不是一个完全简单的追求。你应该停下来考虑是否真的有一个很好的理由,想做到这一点,如果你的目标不能以更简单的方式来实现。
Be warned that this is not a completely straightforward pursuit. You should stop to consider whether you really have a good reason for wanting to do this, and if your goal couldn't be achieved in a simpler way.
这篇关于我怎样才能在不同的应用程序读取窗口,控件的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!