从另一个应用程序复制文本数据
我需要从一些 win 应用程序(不是我的)接收数据。此时应用程序窗口可能处于非活动状态。 我需要的数据在表中表示,因此我无法使用 WM_GETTEXT、WM_COPY,因为它们仅从文本框、文本区域等检索文本。 我可以在此表中手动进行选择,我所需要的只是通过模拟 Ctrl+C 从该选择中复制文本,将数据复制到剪贴板。我尝试以这种方式发送该按键序列
PostMessage(hwnd, WM_KEYDOWN, 0x11, 0x001D0001);
PostMessage(hwnd, WM_KEYDOWN, VkKeyScan('c'), 0x002E0001);
PostMessage(hwnd, WM_CHAR, VkKeyScan('c'), 0x002E0001);
PostMessage(hwnd, WM_KEYUP, VkKeyScan('c'), 0xC02E0001);
PostMessage(hwnd, WM_KEYUP, 0x11, 0xC01D0001);
但也没有成功。这对于记事本非常有用,但不适合我的桌子。 还有其他方法可以从那里获取文本数据吗?
I need to recieve data from some win application (not mine). Application window can be inactive at this time.
Data I need is represented in table, so I am unable to use WM_GETTEXT, WM_COPY because they retrieve text only from texboxes, textareas, etc.
I can manually make a selection at this table and all I need is just copy text from this selection by emulation of Ctrl+C to copy data to clipboard. I tried to send that key sequence this way
PostMessage(hwnd, WM_KEYDOWN, 0x11, 0x001D0001);
PostMessage(hwnd, WM_KEYDOWN, VkKeyScan('c'), 0x002E0001);
PostMessage(hwnd, WM_CHAR, VkKeyScan('c'), 0x002E0001);
PostMessage(hwnd, WM_KEYUP, VkKeyScan('c'), 0xC02E0001);
PostMessage(hwnd, WM_KEYUP, 0x11, 0xC01D0001);
But also have no success. This works great for Notepad but not for my table.
Is there any other way to get text data from there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您提到了 c#,所以我假设另一个 win 应用程序也是 .Net,在这种情况下您可以使用以下技术获取数据: Hawkeye - .Net 运行时对象编辑器
You mention c#, so I'm going to assume the other win app is also .Net in which case you could get the data using techniques such as: Hawkeye - The .Net Runtime Object Editor