IAccessible's accDoDefaultAction ignored by ROLE_SYSTEM_PUSHBUTTON

337 Views Asked by At

im currently working with IAccessible and try to automatically click and do some stuff.

It works fine for several Pushbuttons, Splitbutton and other elements.

The last element is a Windows Systemsetting which is a ROLE_SYSTEM_PUSHBUTTON.

accDoDefaultAction is ignored, same as SendMessage and PostMessage to the Window Handle.

Dummy Code:

private void SetAutoSettingTest()
{
  var RootWindowses = GetWindowsByName("Settings", "ApplicationFrameWindow");
  foreach (var RootWindows in RootWindowses) {
      var AccessableChild = MSAA.GetAccessibleObjectFromHandle(RootWindows.windowHandle);
      var IAccessibleLinkList = new List<IAccessible>();
      MSAA.GetAccessibleObjectListByRole(AccessableChild, "PushButton", ref IAccessibleLinkList, true);
      foreach (var IAccessibleCheckButton in IAccessibleLinkList) {
         AppendLog("Item in Settings AccessableButtonList (found)");
         if (IAccessibleCheckButton.get_accName(0).Equals("MySetting"))
            // it found the proper IAccessible Object. Verified 
            {
            Thread.Sleep(1000); // Just waited if the dialog was not finished WM_PAINT
            IAccessibleCheckButton.accSelect(0); // Was just a try, but didnt help
            IAccessibleCheckButton.accDoDefaultAction(0); // Is ignored
            var MyHandle = MSAA.GetHandle(IAccessibleCheckButton);
            AppendLog("HWND=" + MyHandle );  // It was a IntPtr (HWND)
            int IAccessibleLeft = 0, IAccessibleTop = 0, IAccessibleWidth = 0, IAccessibleHeight = 0;
            IAccessibleCheckButton.accLocation(out IAccessibleLeft, out IAccessibleTop, out IAccessibleWidth, out IAccessibleHeight, 0);
            Win.ShowWindow(RootWindows.windowHandle, Win.SW_SHOW); // just in cae it was minimized
            Win32.BringWindowToTop(MyHandle ); // just in case the Element to toggle was somehow in background
            Win.SetCursorPos(IAccessibleLeft, IAccessibleTop); // Used Mousepos and clicks which works, but not a clean solution
            Win.mouse_event(Win.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
            Win.mouse_event(Win.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
            AppendLog(String.Format("Location Left {0} Top {1} Width {2} Height {3}", IAccessibleLeft, IAccessibleTop, IAccessibleWidth, IAccessibleHeight)); // valid data
            }
         }
     }
} 

It returns a HWND but even PostMessage to the HWND are ignored.

The Role is ROLE_SYSTEM_PUSHBUTTON, State STATE_SYSTEM_FOCUSABLE and the childId CHILDID_SELF. That means it can be accessed and usually toggled. Its not Readonly.

0

There are 0 best solutions below