从 C++ 中的文本框复制文本
具体来说,一个程序正在运行,我想从程序内的文本框中提取文本。
一般来说,我应该使用什么方法/主题来“进入”我的系统上运行的另一个 .exe 并使用 C++ 从其中的文本框中提取数据?
我只是想要一个指导我实现这一目标的方法。 谢谢。
Specifically, a program is running and I want to extract the text from a text box inside the program.
Generally, what methods/topics should I be using to "get inside" another .exe running on my system and extract data from a text box inside it using C++?
I just want a pointer towards the way in which I might achieve this. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您只需将
EnumChildWindows
和SendMessage
与WM_GETTEXT
一起使用到您想要从中获取文本的特定窗口。You can simply use
EnumChildWindows
andSendMessage
withWM_GETTEXT
to the specific window you want to get the text from.“进入”GUI 应用程序(特定于 Windows)的另一种常见技术是 DLL 注入 + Windows 子类化。 这可能被认为是有点高级的 Windows 编程,关于该主题的优秀书籍是“Windows Via C/C++”。 简单来说,这本质上是:
另请注意,我上面提到的任何内容都不是以任何方式“破解 Windows”,这是 Microsoft 故意实施的明确定义的行为。 实际上,它在 MSDN 上有很好的记录。
如果您想这样做,请查看“Windows Subclassing”和“Setting Hooks”。
Another common technique for 'getting inside' a GUI application (windows specific) is DLL Injection + Windows Subclassing. This is probably considered somewhat advanced windows programming an excellent Book on the subject is 'Windows Via C/C++'. A brief idea of what this about is essentially:
Also note that nothing I have mentioned above is in any way 'hacking windows' this is a well defined behavior which was implemented purposely by Microsoft. Its quite well documented over on MSDN actually.
If you want to do this have a look at 'Windows Subclassing' and 'Setting Hooks'.
请参阅我如何构建一个可用的在线扑克Bot:从第 3 方应用程序中提取文本,以解释 @DeusAduro 提到的注入和子类技术以及其他一些技术,例如挂钩 GDI 文本输出 API。 当然,如果它是标准文本框,您始终可以发送 WM_GETTEXT,这甚至可以跨进程边界工作(实际上被设计为跨进程边界工作)。
See How I Built a Working Online Poker Bot: Extracting Text from 3rd-Party Applications for an explanation of the inject-and-subclass techniques mentioned by @DeusAduro as well as a couple other techniques for the same, such as hooking the GDI text-output APIs. And of course if it's a standard textbox you can always send a WM_GETTEXT this works even across process boundaries (was designed to work across process boundaries in fact).