On Windows the accessibility APIs give you this. And as these same APIs are used for screen readers, automated testing, and AI access, supporting them is definitely worthwhile.