def script_calculatorResult(self, gesture):
# To prevent double focus announcement, check where we are.
focus = api.getFocusObject()
navMenu = False
if isinstance(focus, UIA) and isinstance(focus.parent.parent, UIA) and focus.parent.parent.UIAElement.cachedAutomationID == "FlyoutNav":
navMenu = True
gesture.send()
# In redstone, calculator result keeps firing name change, so tell it to do so if and only if enter has been pressed.
self.shouldAnnounceResult = True
# Hack: only announce display text when an actual calculator button (usually equals button) is pressed.
# In redstone, pressing enter does not move focus to equals button.
if isinstance(focus, UIA):
if focus.UIAElement.cachedAutomationID == "CalculatorResults":
queueHandler.queueFunction(queueHandler.eventQueue, focus.reportFocus)
elif focus.UIAElement.cachedAutomationID != "NavButton":
# In newer releases, result is located on the same spot in the object hierarchy.
result = api.getForegroundObject().children[1].children[3]
if result.UIAElement.cachedAutomationID == "CalculatorResults" and not navMenu:
# And no, do not allow focus to move.
queueHandler.queueFunction(queueHandler.eventQueue, result.reportFocus)
评论列表
文章目录