If you’re willing to use JXA, the Core Graphics framework might be able to enumerate the full list of windows.
It contains some low-level C APIs, one of which in particular seems pertinent:
CGWindowListCopyWindowInfo()
.
It takes two arguments, which you can probably just pass 0
for each:
ObjC.import('CoreGraphics');
ObjC.deepUnwrap($.CGWindowListCopyWindowInfo(0, 0));