Some time ago, I demonstrated enumerating notification icons via UI Automation. Part of the exercise was enumerating the icons in the overflow area. This was done by finding the button that expands the overflow area, clicking it, and then enumerating the icons in the flyout. But can it be done without showing them?
No, or at least, not from UI Automation.
UI Automation is not an object model for application content. It is an object model for UI objects.
Being an object model for UI objects implies that if something is not represented by UI objects, then UI Automation has no obligation to represent it.
The postal service is not required to maintain records for buildings that do not exist. Now, it might, for its own internal reasons, choose to keep records for buildings that recently existed, or records for buildings that are planned to exist soon, but its obligation is to deliver mail to buildings that exist right now.
In order to make something visible to UI Automation, you have to make it appear in the UI, and for overflow notification icons, that means opening the overflow flyout so that the icons become visible.
Similarly, there is no way to use UI Automation to enumerate the hidden notification icons. If the icon is hidden, then there is no UI for it, which means that there is nothing for UI Automation to operate on.
Some programs provide object models for their content. For example, Office apps have a rich document object model that allows you to manipulate documents like Excel spreadsheets via script. Whether any particular program offers such an object model is a case-by-case question.
In the case of the taskbar, there is no supported object model for notification icons. UI Automation is the best you can do.
0 comments
Be the first to start the discussion.