简体   繁体   English

获取外部程序句柄

[英]Getting a external programs handle

I made a small program in C++ that can type text into a notepad document, it does so using FindWindow and FindWindowEx, but I was only able to do that because I knew the names of the windows I was trying to access (in this case it was "Notepad" for the doc and "Edit" for the text area). 我用C ++编写了一个小程序,可以使用FindWindow和FindWindowEx在记事本文档中键入文本,但是我只能这样做,因为我知道我要访问的窗口的名称(在这种情况下,是文档的“记事本”和文本区域的“编辑”。

If I didn't know the names how would I go about figuring that out? 如果我不知道名字,我将如何解决呢? Lets hypothetically say I wanted to make text appear in Chrome's URL box, how would I figure out what the name of that box is so I can use FindWindowEx on it? 假设我们想让文本显示在Chrome的URL框中,我如何确定该框的名称,以便可以在其中使用FindWindowEx?

The least painful approach to automating 3rd party applications is to use UI Automation . 使第三方应用程序自动化的最简单的方法是使用UI自动化 It allows you to navigate UI hierarchies as well as operate on the individual objects. 它允许您导航UI层次结构以及对单个对象进行操作。

All native windows controls support UI Automation out of the box. 所有本机Windows控件均支持开箱即用的UI自动化。 UI Automation also works with frameworks, that do not implement their UI using native controls (eg Qt). UI Automation还可以与不使用本机控件(例如Qt)实现UI的框架一起使用。 Particularly with Qt, tools like Spy++ will not give you the information you need. 特别是对于Qt,像Spy ++这样的工具将无法为您提供所需的信息。

运行另一个应用程序,然后使用Spy ++,Winspector等工具查看另一个程序的窗口层次结构,以查找所需的内容。

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

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