Win32API 复制 Spy++ Python 中的窗口信息功能
我有一个第三方 GUI 程序,我用 Python 类(使用 ctypes)包装它。
是否有 Win32 API 函数可以执行以下操作?
1) 获取给定屏幕位置的窗口的窗口句柄。
2) 获取具有给定标题的按钮或静态窗口的窗口句柄。
3) 将文本发送到编辑窗口。
4) 从 RICHEDIT 实例中提取文本。
我有 WinSpy(一个 Spy++ 类型的应用程序),并且知道可以使用该工具获取窗口句柄和标题,但我需要在 Python 中工作的东西。
我认为 Python 的 ctypes 可以让我访问 Win32 API 中的任何函数,因此我一直在扫描 MSDN(尤其是 此窗口/消息部分)。我似乎找不到任何有效的东西。
谢谢,
迈克
I have a third-party GUI program that I'm wrapping with a Python class (using ctypes).
Are there Win32 API functions that can do the following?
1) Obtain the window handle for a window at a given screen location.
2) Obtain the window handle for a Button or Static window with a given caption.
3) Send text to an Edit window.
4) Extract text from a RICHEDIT instance.
I have WinSpy (a Spy++-type app) and know that it's possible to obtain window handles and captions using that tool, but I need something that works within Python.
I assume that Python's ctypes gives me access to any function within the Win32 API, so I've been scanning MSDN (especially this windows/messages section). I can't seem to find anything that works.
Thanks,
Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WindowFromPoint
FindWindowEx
查找窗口的子窗口给定的类和名称(标题)。重复操作以打通每个父子间接关系。EnumChildWindows
也很有帮助。< /p>SendMessageTimeout
+WM_SETTEXT
SendMessageTimeout
+WM_GETTEXT
或EM_STREAMOUT
WindowFromPoint
FindWindowEx
to find a child of a window with a given class and name (caption). Repeat operation to get through each parent-child indirection.EnumChildWindows
can be helpful too.SendMessageTimeout
+WM_SETTEXT
SendMessageTimeout
+WM_GETTEXT
orEM_STREAMOUT
我很难找到一个非常简单的 WM_GETTEXT 与 pywin32 示例,并认为这里可能是添加一个的好地方,因为它回答了部分问题:
I had trouble finding a very simple example for WM_GETTEXT with pywin32 and figured here might be a good place to add one, since it answers part of the question: