Windows UI Automation doesn't recognize button controls : <p>I'm having problems trying to identify via <em>Windows UI Automation</em> the button controls that are inside the <em>Notification Area</em> window (classname: <strong>ToolbarWindow32</strong>):</p>

<p><a href="https://i.stack.imgur.com/lwe5c.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lwe5c.png" alt="enter image description here"></a></p>

<p>I verified via the <em>Windows UI Automation</em> tools deployed in the <em>Windows SDK</em> that those "icons" are controls of type <code>ControlType.Button</code>, however when I try to run the code below I get a null-reference exception because the search condition I use doesn't get any control.</p>

<p>I'm doing something wrong, or maybe I found some kind of limitation in <em>Windows UI Automation</em> ?</p>

<p>This is the code, I mixed it with WinAPI calls just to facilitate the task for the helper users who maybe preffers to use that methodology.</p>

<pre><code>Dim tskBarClassName As String = "Shell_TrayWnd"
Dim tskBarHwnd As IntPtr = NativeMethods.FindWindow(tskBarClassName, Nothing)

Dim systrayBarClassName As String = "TrayNotifyWnd"
Dim systrayBarHwnd As IntPtr = NativeMethods.FindWindowEx(tskBarHwnd, IntPtr.Zero, systrayBarClassName, Nothing)

Dim ntfyBarClassName As String = "ToolbarWindow32"
Dim ntfyBarHwnd As IntPtr = NativeMethods.FindWindowEx(systrayBarHwnd, IntPtr.Zero, ntfyBarClassName, Nothing)

Dim window As AutomationElement = AutomationElement.FromHandle(ntfyBarHwnd)
Dim condition As New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button)
Dim button As AutomationElement = window.FindFirst(TreeScope.Descendants, condition)

MsgBox(button.Current.Name) ' Here throws the null-reference exception.
</code></pre>

<p>Any solution for this?</p>
