I am attempting to scrape data from a datagrid inside a windows application.
I have successfully scraped the data from textboxes in the application using the User32.dll and its methods such as GetWindow to find the handles and then using SendMessage to read the content.
[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);
My problem is that these methods don’t seem to return any values for a DataGrid or table.
Does anyone have any advice on how I might be able to achieve this?
This is possible by using UI Automation API. I hope these links help you find the needed solution: Discussion of similar problem,UI Automation Support for the DataGrid Control Type. Although specific solution depends on many implementation details of the datagrid.