none
why I get position coordination(0,0,1,1)(left, top, width, height) with IAccessible->accLocation?

    Question

  • I try to use IAccessible->accLocation to get some child element's position information in some metro applications like "finance", why I get position coordination(0,0,1,1)(left, top, width, height) ? how can I get the real position like (10,10,125,125).Is there other ways?

    Wednesday, January 30, 2013 6:50 AM

Answers

  • I'd recommend using UIAutomation instead of IAccessible. I don't know which specific elements you are having trouble with, but I get valid BoundingRectangles with UIA for everything in a quick overview of the Finance app.

    --Rob

    • Marked as answer by artherx2002-1 Wednesday, February 13, 2013 2:35 AM
    Wednesday, January 30, 2013 11:35 PM
  • I have no problem finding the Bounding Rectangle of the News item in the navigation bar. It may help if you provided code to demonstrate what you are doing that isn't working. I'll also move this to a more appropriate forum for you.

    Finance app's News item with Boundaries shown in Inspect

    --Rob

    • Marked as answer by artherx2002-1 Wednesday, February 13, 2013 2:35 AM
    Tuesday, February 05, 2013 3:08 AM

All replies

  • I'd recommend using UIAutomation instead of IAccessible. I don't know which specific elements you are having trouble with, but I get valid BoundingRectangles with UIA for everything in a quick overview of the Finance app.

    --Rob

    • Marked as answer by artherx2002-1 Wednesday, February 13, 2013 2:35 AM
    Wednesday, January 30, 2013 11:35 PM
  • Thanks, Rob. The elements I have trouble with is named "news"(Finance-Application Bar- news). I can now get it's name but cannot get it's position coordination correctly(0,0,1,1). I will try the way you said(UIAutomation). I will reply here again if I cannot succeed.
    Monday, February 04, 2013 1:39 AM
  • Hi, Mr. Rob, I have done as you told me, that use UIAutomation instead of IAccessible, but failed. The windows of the finance application, "Windows.UI.Core.CoreWindow--Web Platform Embedding--Internet Explorer_Server"I can get the son of "Web Platform Embedding", it is"Internet Explorer_Server". But the children I really want to get is Navigation Bar Items( like "news", "Current Market",see picture2) name and coordinations. Do you have any good ideal?

    Monday, February 04, 2013 8:44 AM
  • I have no problem finding the Bounding Rectangle of the News item in the navigation bar. It may help if you provided code to demonstrate what you are doing that isn't working. I'll also move this to a more appropriate forum for you.

    Finance app's News item with Boundaries shown in Inspect

    --Rob

    • Marked as answer by artherx2002-1 Wednesday, February 13, 2013 2:35 AM
    Tuesday, February 05, 2013 3:08 AM
  • thanks , Rob. I can get the text item name and Bounding Rectangle, but I cannot get any items on Navigation Bar. the following is my codes. Thanks again! I have these questions: 1) Why this code cannot get Navigation Bar Items, it should get all children items.  2)I also want to know if  keyboard focus is current on the bar items, Which API function may I use?  3) About CreatePropertyCondition, I used the condition by name "Navigation Bar" (this Line is comment out in the following code), then I get none child item.  Why?

        LPWSTR szBarName = L"Navigation Bar";
        CoInitialize(NULL);

          HRESULT hrGetElement = CoCreateInstance(CLSID_CUIAutomation, NULL, CLSCTX_INPROC_SERVER, IID_IUIAutomation, reinterpret_cast<void**>(&g_pIUAutomation));


        hrGetElement = g_pIUAutomation->ElementFromHandle(hExplorer_Server, &pFinanceElement1);
        if (hrGetElement == S_OK)
        {
         hrGetElement = g_pIUAutomation->CreateTrueCondition(&pCondition);
         //hrGetElement = g_pIUAutomation->CreatePropertyCondition(UIA_NamePropertyId, varName, &pCondition);
         if (hrGetElement == S_OK)
         {
          for (int i =0 ;i<10;i++)
          {
           hrGetElement = pFinanceElement1->FindAll(TreeScope_Subtree,pCondition,&pFinanceChildrenArray1);//TreeScope_Descendants
           pFinanceChildrenArray1->get_Length(&intChildCount);
           for (int i = 0; i <intChildCount; i++)
           {
            pFinanceChildrenArray1->GetElement(i, &pFound);
            hrGetElement = pFound->get_CurrentName(&bstrName);
            if (hrGetElement != S_OK)
             continue;

            bstrTName = bstrName;
            strcpy(pszName,bstrTName);      
            pFound->get_CurrentBoundingRectangle(&childRect);
           }
          }
         }
        }

        SysFreeString(bstrName);
        ::CoUninitialize();

    Tuesday, February 05, 2013 6:41 AM
  • And one more question is, when the menu bar isn't showing on the screen, Can I get the items name and  Bounding Rectangle?
    Tuesday, February 05, 2013 8:06 AM
  • Mr. Rob , I have know that the reason I get position coordination(0,0,1,1), is the menu bar isn't showing on the screen currently. If it shows I get position coordination(10,10,125,125), but when it isn't showing, I get position coordination(0,0,1,1). And I can get coordination use UIAutomation now. Thank you very much!
    Wednesday, February 13, 2013 2:35 AM