Doesn't sleep when I would expect no activity.
Opened this issue · 1 comments
The readme states "sleeps when no resizing taking place to 0% CPU usage". However, you will notice it working often in the background when no changes to the taskbar are taking place. If you run it in debugging mode you will see there are a high volume of "WindowClosedEvent" that aren't visible. I must assume that the OS generates these events for smaller "Window" objects that don't have a taskbar icon. I have attempted to find a better way of detecting Taskbar object close events and I have not yet been able to do so.
I did notice that listening to "WindowOpenedEvent" is superfluous. The BoundingRectangleProperty catches new Taskbar items just fine without it. It does not catch objects leaving the taskbar.
We either need to filter WindowClosedEvent to only generate for taskbar items or find a different event that doesn't false fire so often.
BoundingRectangleProperty shouldn't catch new items as that would have no impact on the rectangle size when windows are opened. BoundingRectangleProperty only catches when the UI occasionally redraws the taskbar and moves things back to the original position. When new items are added to the task bar the size does not change (its not sized to fit its children but instead sized based around its siblings). Adjusting to the width to fit the children triggers a redraw and messes everything up, tried that.
I've tried a number of UIAutomation events and properties and have not been able to find a better solution. I've tried watching the BoundingRectangleProperty of a number of elements (the ideal one would be the invisible accessibility element at the end of the list of children) but this doesn't trigger any events, none of the child task bar button elements do. I've tried AddStructureChangedEventHandler, I've tried BoundingRectangleProperty, PositionInSetProperty all with no success. I also have not found a good way to filter out the noise for the closed event directly but that's partly why the old positions are cached so that the position loop can quickly terminate without a ton of calculations when those false calls happen.
I'm open to any suggestions but I think I've gone through most of the available events that Microsoft has documented in UIAutomation and can't find one that works better than the current solution