5

I want to read a 'DataGridView' of an application. There is an application in which many child windows are there. Here is a picture of that application and the window containing the datagridview which I want to read, I've highlighted the window which I want to read

application

I've searched the window through UISPY and here is the picture of the window and datagridview in it. I've highlighted the control which I want to be read.

enter image description here

I've used this code(Winapi) to read the control but I am getting an empty string

public object WindowText(IntPtr hWnd)
{
    object obj2 = "";
    if (hWnd.Equals(IntPtr.Zero))
    {
        return "";
    }
    // 0x111 is WM_COMMAND
    MainModule.SendMessage(hWnd, 0x111, (IntPtr)0x81eb, IntPtr.Zero);
    MainModule.StrData = MainModule.StrData + Clipboard.GetText();
    // 0x307 is WM_DESTROYCLIPBOARD
    MainModule.SendMessage(hWnd, 0x307, IntPtr.Zero, IntPtr.Zero);
    return obj2;
}

I've also tried UI Automation but i didn't succeed in reading through it also.
The datagridview has some cells which are updated every second(Live data) and I want to read it and store it. I want to read the the cells and columns(Symbol,Bid,Ask) and the cell contents(AUDCAD,AUDCHF) etc.

brasofilo
  • 25,496
  • 15
  • 91
  • 179
Ishaq Gi
  • 103
  • 8
  • I don't understand what you are trying to do with these `SendMessage` – manuell Jan 16 '14 at 15:29
  • its a winapi instance of reading the contents of another application like this http://i.stack.imgur.com/rnvwI.jpg – Ishaq Gi Jan 16 '14 at 15:36
  • Try WM_GETTEXT http://msdn.microsoft.com/en-us/library/windows/desktop/ms632627%28v=vs.85%29.aspx If this is not a custom control then each cell should contain an "edit"-control. For example Powerbuilder has a grid control which hasn't edit controls. they draw the whole control and not a list of edit controls. – user743414 Jan 16 '14 at 15:45
  • Try this **http://stackoverflow.com/questions/10488304/how-to-capture-data-in-a-window**. maybe you can use the information provided there, as there are some similarities. – alphabit Jan 22 '14 at 22:36

1 Answers1

0

UI Spy uses UI Automation, not windows messages. Since the control claims to be a datagrid, you should be able to find the item by looking for the element with UIA_ControlTypePropertyId equal to UIA_DataGridControlTypeId, and then examining the children as appropriate.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71