简体   繁体   English

如何从不同应用程序中的窗口控件读取数据?

[英]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? 从其他应用程序访问Windows并从控件获取数据的最佳方法是什么?

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. 您需要P / Invoke FindWindowFindWindowEx函数来检索其他应用程序的父窗口和子控件的句柄。

Then you will need to use something like GetWindowText to access the text for a particular control. 然后,您将需要使用类似GetWindowText来访问特定控件的文本。

Visit pinvoke.net for the definitions you'll need to call these functions from C#. 访问pinvoke.net,了解从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. 你应该停下来考虑你是否真的有充分的理由想要这样做,如果你的目标无法以更简单的方式实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM