Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8237262

Java Access Bridge API cannot get correct iaccessible context info

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      When I try to get UI element in PyCharm and its ancestors' information, sometimes wrong info could be returned: the indexInParent field in AccessibleContextInfo is -1.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Install PyCharm. This program is written in Java, so Java Access Bridge can be used to get UI element information of this program.
      2. Write a C++ program to call functions in Java Access Bridge.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      1. Correct accessibility info could be collected, the indexInParent field in AccessibleContextInfo must not be -1.
      ACTUAL -
      1. Wrong accessibility info is collected, the indexInParent field in AccessibleContextInfo is -1.

      ---------- BEGIN SOURCE ----------
      1. Here is part of C++ source code:
      POINT point;
      GetCursorPos(&point);
      HWND h = WindowFromPoint(point);

      if (!IsJavaWindow(h))
      {
        return;
      }

      AccessibleContext root_ac;
      long vmId;
      if (!GetAccessibleContextFromHWND(h, &vmId, &root_ac))
      {
        return;
      }

      AccessibleContext ac;

      if (!GetAccessibleContextAt(vmId, root_ac, point.x, point.y, &ac))
      {
        return;
      }
      AccessibleContextInfo info;

      if (!GetAccessibleContextInfo(vmId, ac, &info))
      {
        return;
      }

      OutputDebugStringW(L"------------------------------------\n");
      AccessibleContext pAc;
      while (ac)
      {
        AccessibleContextInfo info;
        GetAccessibleContextInfo(vmId, ac, &info);

        HWND hwnd = getHWNDFromAccessibleContext(vmId, ac);
        char txt[256];
        sprintf_s(txt, "info = %d %d %d %d %d %d\n", info.childrenCount, info.indexInParent, info.x, info.y, info.width, info.height); // Sometimes the indexInParent field is -1.
        OutputDebugStringA(txt);

        pAc = GetAccessibleParentFromContext(vmId, ac);
        ac = pAc;
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Not known.


        Attachments

          Activity

            People

            • Assignee:
              pbansal Pankaj Bansal
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: