我正在尝试从 Windows 应用程序中的数据网格中抓取数据。
我已经使用 User32.dll 及其方法(例如 GetWindow
)成功地从应用程序的文本框中抓取数据来查找句柄,然后使用 SendMessage
读取内容。
[DllImport("user32.dll", EntryPoint = "GetWindow", SetLastError = true)]
internal static extern IntPtr GetWindow(IntPtr lpWindHandle, uint lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam);
我的问题是这些方法似乎没有为 DataGrid
或 table
返回任何值。
有人对我如何实现这一目标有任何建议吗?
最佳答案
这可以通过使用 UI 自动化 API 来实现。我希望这些链接可以帮助您找到所需的解决方案:Discussion of similar problem, UI Automation Support for the DataGrid Control Type .虽然具体的解决方案取决于数据网格的许多实现细节。
关于c# - 如何从 Windows 应用程序中抓取数据网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11393875/