Code: Select all
UIA := UIA_Interface()
OutlookMainID := WinExist("ahk_exe outlook.exe")
elementMain := UIA.ElementFromHandle(OutlookMainID)
homeTab := elementMain.FindFirstByNameAndType("Home","TabItem")
handler := UIA_CreateEventHandler("TabItemSelectedEventHandler")
UIA.AddAutomationEventHandler(UIA_Enum.UIA_SelectionItem_ElementSelectedEventId, homeTab,,,handler) ; or if it doesn't work, try using elementMain here
OnExit("Cleanup")
return
Cleanup() {
UIA_Interface().RemoveAllEventHandlers()
}
TabItemSelectedEventHandler(sender, event) {
ToolTip, Selected!
}
Alternative options:
1) Add a FocusedChanged event listener (though this didn't work in Outlook 365 either...)
2) Create a ~LButton hotkey and check if the element under the cursor is the Home tab item element.
EDIT: PropertyChangedEvent seems to work:
Code: Select all
#Include <UIA_Interface>
UIA := UIA_Interface()
OutlookMainID := WinExist("ahk_exe outlook.exe")
elementMain := UIA.ElementFromHandle(OutlookMainID)
homeTab := elementMain.FindFirstByNameAndType("Home","TabItem")
handler := UIA_CreateEventHandler("HomeTabSelected", "PropertyChanged")
UIA.AddPropertyChangedEventHandler(homeTab,,,handler, [UIA_Enum.UIA_SelectionItemIsSelectedPropertyId])
OnExit("Cleanup")
return
Cleanup() {
UIA_Interface().RemoveAllEventHandlers()
}
HomeTabSelected(sender, propertyId, newValue) {
ToolTip, % "Sender: " sender.Dump()
. "`nPropertyId: " propertyId
. "`nNew value: " newValue
}