获取自定义.NET类的窗口句柄组件类型句柄、自定义、组件、窗口

2023-09-06 23:17:07 作者:转身的微笑

我需要看到的组件类型,这意味着被编程的点击的控制在另一个进程中,类的名称。我需要的那种类型,所以我可以作出反应,点击的控制,然后做一些自动化的任务。 现在我做了以下内容: 1.我的FindWindow()从Win32的查找过程的主要窗口句柄。 2.然后,我得到调用EnumChildWindows(),也从Win32中,并获得主窗口的句柄的所有孩子的窗口句柄。 3.现在它变得非常棘手。当我打电话GetClassName(),它返回WindowsForms10.STATIC.app [...]因为我想读的控制是自定义的。

I need to see the component type, meaning the name of the class that was programmed, of a clicked control in another process. I need the type so I can react to the clicked control and then do some Automation tasks. Right now I am doing the following: 1. I FindWindow() from Win32 to find the main window handle of the process. 2. Then, I get call EnumChildWindows(), also from Win32, and get the window handles of all the children of the main window handle. 3. Now it gets tricky. When I call GetClassName(), it returns WindowsForms10.STATIC.app [...] since the controls I am trying to read are custom.

我怎样才能用窗口单击控件的类型从EnumChildWindows处理()?就是我试图做甚至可能吗? 我一直在寻找到使用的SendMessage()从Win32的的过程,但它似乎没有系统定义的消息,可以帮助。

How can I get the type of the clicked control using the window handles from EnumChildWindows() ? Is what I am trying to do even possible? I have been looking into using SendMessage() from Win32 to the process but it seems that there is no system defined message that could help.

推荐答案

恐怕,这是不可能的。手柄只是指Windows需要在窗口内部数据。没有超出该无资料。

I'm afraid that it's not possible. A handle just refers to internal data of the window that Windows needs. There is no information beyond that available.

您可以获取类名,但它既不规范,也不是唯一的。大多数控制是不一样的按钮,列表等基本功能性控制是来自于一个非常原始的之一,即静态。但同样,也没有对现有的高层次的WinForms控制信息。

You can get the class name, but it is neither standardized nor unique. Most controls that are not basic-functionality controls like buttons, lists, etc. are derived from a very primitive one, namely "Static". But again, there's no information about the high-level WinForms control available.

这导致了一个事实,即使你知道的类型,你不能只投指针/句柄,因为它背后有没有数据。

This leads to the fact that, even if you knew the type, you cannot just cast the pointer/handle, because there no data behind it.

你能以某种方式重述问题了吗?也许使用远程过程调用?是否没有高层次的WinForms对象的工作?比如像点击,移动或重命名工作,普通的Win32 API。

Can you somehow restate your problem? Maybe use Remote Procedure Calls? Does it work without the high-level WinForms objects? Things like clicking, moving or renaming work with plain Win32 API.