def locateElement(self, automationID):
# Foreground isn't reliable.
fg = api.getForegroundObject()
if fg.getChild(1).childCount > 0:
screenContent = fg.getChild(1)
else:
screenContent = fg.getChild(2)
# Thanks to My Peple in Fall Creators Update, screen content so far could actually be the title bar, and the actual foreground window is next door.
# In other words, Skype window is embedded inside My People window.
if screenContent.UIAElement.cachedAutomationID == "TitleBar":
# The following traversal path may change in future builds.
screenContent = screenContent.next.simpleLastChild.simpleFirstChild
# Element placement (according to UIA changes from time to time.
# Wish there is a more elegant way to do this...
for element in screenContent.children:
if isinstance(element, UIA) and element.UIAElement.cachedAutomationID == automationID:
return element
return None
# Name change cache (yet again)
# In some cases, Skype message fires name change, and a related element fires live region changed event.
评论列表
文章目录