Ответ 1
Я проверил с помощью средств автоматизации Windows UI, развернутых в SDK Windows, что эти "значки" являются элементами управления типа ControlType.Button
Вы правы несколько. Технически они не находятся в ToolbarWindow32, а скорее в Shell_TrayWnd. Я проверил область и выяснил, что эти кнопки на самом деле находятся в ToolBar
, поэтому вам нужно искать ControlType.ToolBar
. Затем вам нужно FindAll
, которое вернет все AutomationElements, которые удовлетворяют PropertyCondition
...
Примечание. Первый цикл - это получить зону расширенного пользовательского уведомления. Следующий цикл для развлечения - это кнопки Running Application... (КОД РАБОТАЕТ НА WIN7, WIN8 и WIN10)
Здесь, в моем примере ниже, я иду за Shell_TrayWnd
, который доставит нам то, что нам нужно. Затем я просматриваю и обнаруживаю, что ToolBar
мы после, затем прокручиваем и FindAll
ControlTypes Button
...
Dim arrText As New List(Of String)
Dim tskBarClassName As String = "Shell_TrayWnd"
Dim tskBarHwnd As IntPtr = FindWindow(tskBarClassName, Nothing)
Dim window As AutomationElement = AutomationElement.FromHandle(tskBarHwnd)
Dim condition As New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ToolBar)
Dim elementCollection As AutomationElementCollection = window.FindAll(TreeScope.Descendants, condition)
'for fun get all we can...
For Each aE As AutomationElement In elementCollection
If aE.Current.Name.Equals("User Promoted Notification Area") Then
For Each ui As AutomationElement In aE.FindAll(TreeScope.Descendants, New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button))
arrText.Add("Notification Area - " & Replace(ui.Current.HelpText, Chr(10), " "c)) 'removed line break as when shown it would show some on a new line in messagebox
Next
ElseIf aE.Current.Name.Equals("Running applications") Then
For Each ui As AutomationElement In aE.FindAll(TreeScope.Descendants, New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button))
arrText.Add("Toolbar Area - " & Replace(ui.Current.Name, Chr(10), " "c)) 'removed line break as when shown it would show some on a new line in messagebox
Next
End If
Next
If arrText.Count > 0 Then
MessageBox.Show(String.Join(Environment.NewLine, arrText.ToArray))
End If
Если у вас есть какие-либо вопросы, пожалуйста, дайте мне знать. Изображение ниже (некоторые вещи, которые я прокомментировал по соображениям безопасности)