Accessibility API - Access kAXDocumentAttribute of hidden fullscreen windows or tabbed documents

Hello!


I am using the accessibility API (AXUIElementCreateApplication, ...) to watch all opened documents within an application.


For this I obtain the root element of the application via AXUIElementCreateApplication, iterating recursively through it's child windows (reading kAXChildrenAttribute, kAXWindowsAttribute and kAXMainWindowAttribute) and checking the unique path of the opened documents by reading the kAXDocumentAttribute of each window element (elements having the kAXRoleAttribute "AXWindow").


This works pretty reliable and is supported by all document based applications (can simply be tested with TextEdit), however if I want to scan the application for a document window which has multiple documents opened in full screen mode (e.g. by clicking the green full screen icon in the document window's title bar, shifting the full screen window beside by pressing Ctrl + right arrow key and making another document window of that application full screen) not all document windows appear in the accessibility tree now.


With the kAXMainWindowAttribute I can access the top level window, but if the application has multiple full screen windows, they are no more accessible. The kAXChildrenAttribute and kAXWindowsAttribute do not contain any full screen window. Even if the full screen windows are not "hidden", underlying documents which are not the main window are not accessible.


If the observing application has still a retained handle (AXUIElementRef) to a window which is turned into full screen and then covered by another full screen document window of that application, the handle remains still valid and the window and it's kAXDocumentAttribute can still be accessed, but when starting a fresh iteration with AXUIElementCreateApplication (e.g. this is required when the observing application is restarted), there is no access.


Furthermore if a document is opened in a tab (This can be done by e.g. opening multiple documents with TextEdit and then selecting "Window -> Merge All Windows" from the menu or opening a document with TextEdit, putting this window to full screen, and opening a second document with TextEdit, and now TextEdit will open the second document within a tab of the full screen window), the kAXDocumentAttribute cannot be accessed from documents which are not the main window but only tabbed. Only the label of the tab (kAXTitleAttribute of elements with "AXTabButton" sub role) can be obtained, but this is not unique, as multiple documents from different locations can have the same file name.
As with full screen windows all retained AXUIElementRef handles remain still valid.

A list of all documents could be obtained through the dock menu of the application, but there is no kAXDocumentAttribute which would identify a document distinctly and a distinction between open documents and suggestions from recently opened documents is difficult. And different applications use the doc menu in a different way.


Using the AccessibilityInspector from Xcode reflects this observations.


Has there anybody any ideas how to access the kAXDocumentAttribute in this cases?
Or should this be seen as a bug of the accessibility API?
Used macOS version: 10.14.6 Mojave
The problems are also existing in earlier versions of macOS.


Regards,
Dominik