def script_easyNavigationPreviousItem(self, gesture): global easyNavigationRing treeInterceptor = api.getFocusObject().treeInterceptor scriptHandler.executeScript( getattr(treeInterceptor, easyNavigationRing.getItem(self.ringIndex).previous), gesture)
def sayCurrentLine(): global instanceGP if not braille.handler._auto_scroll: if getTether() == braille.handler.TETHER_REVIEW: if config.conf["brailleExtender"]["speakScroll"] in [ addoncfg.CHOICE_focusAndReview, addoncfg.CHOICE_review ]: scriptHandler.executeScript( globalCommands.commands.script_review_currentLine, None) return if config.conf["brailleExtender"]["speakScroll"] in [ addoncfg.CHOICE_focusAndReview, addoncfg.CHOICE_focus ]: obj = api.getFocusObject() treeInterceptor = obj.treeInterceptor if isinstance(treeInterceptor, treeInterceptorHandler.DocumentTreeInterceptor ) and not treeInterceptor.passThrough: obj = treeInterceptor try: info = obj.makeTextInfo(textInfos.POSITION_CARET) except (NotImplementedError, RuntimeError): info = obj.makeTextInfo(textInfos.POSITION_FIRST) info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, unit=textInfos.UNIT_LINE, reason=REASON_CARET)
def onDefaultAction(self, event): self.Hide() obj = self.getObjectFromList().obj api.setNavigatorObject(obj) try: scriptHandler.executeScript(globalCommands.commands.script_review_activate, None) except: ui.message(_("Can not do default action for this object"))
def onOptionsButton(self, event): self.Hide() self.options.scrollIntoView() api.setNavigatorObject(self.options) try: scriptHandler.executeScript( globalCommands.commands.script_review_activate, None) except: beep(150, 100)
def tbContextMenu(self, obj, func): api.setNavigatorObject(obj) x = obj.location[0] + 2 y = obj.location[1] + 2 winUser.setCursorPos(x, y) if api.getDesktopObject().objectFromPoint(x, y) == obj: scriptHandler.executeScript(func, None) else: # TRANSLATORS: Message shown when the object is not found ui.message(_("Not found"))
def script_reportCurrentSelection(self, gesture): if self.startSelection < 0\ or self.fakeCaret == self.startSelection or not self.value: scriptHandler.executeScript(commands.script_reportCurrentSelection, None) return speech.speakText(_("selected")) if self.startSelection > self.fakeCaret: speech.speakText(self.value[self.fakeCaret:self.startSelection]) else: speech.speakText(self.value[self.startSelection:self.fakeCaret])
def script_doAction(self, gesture): obj = api.getNavigatorObject() if obj.parent == self: if obj.actionCount > 0: scriptHandler.executeScript( globalCommands.commands.script_review_activate, KeyboardInputGesture) else: scriptHandler.executeScript(self.script_menu, None) else: beep(200, 80)
def script_nextSetRotor(self, gesture): if rotorItem in [ROTOR_MOVE, ROTOR_SELECT]: return self.switchSelectionRange() elif rotorItem == ROTOR_OBJ: self.sendComb('nvda+shift+downarrow', gesture) self.showBrailleObj() elif rotorItem == ROTOR_REVIEW: scriptHandler.executeScript( globalCommands.commands.script_braille_nextLine, gesture) elif rotorItem == ROTOR_TABLES: self.sendComb('control+alt+downarrow', gesture) else: return self.sendComb('downarrow', gesture)
def sayCurrentLine(): global instanceGP if (configBE.conf['general']['speakScroll'] or configBE.conf['general']['alwaysSpeakScroll'] ) and not instanceGP.autoScrollRunning: try: if braille.handler.tether == braille.handler.TETHER_REVIEW: scriptHandler.executeScript( globalCommands.commands.script_review_currentLine, None) ui.message(unicode(self.rawText).replace('\0', '')) elif configBE.conf['general']['alwaysSpeakScroll']: speech.speakMessage(getLine()) except BaseException: pass
def script_skipPreviousOutside(self, gesture): obj = self.previousOutsideObject while obj: if obj.isFocusable: api.setFocusObject(obj) if controlTypes.STATE_FOCUSED in obj.states: return obj = obj.previous if self.container.simpleParent.role == controlTypes.ROLE_DIALOG: api.setNavigatorObject(self.focusableContainer) scriptHandler.executeScript( globalCommands.commands.script_review_activate, None) pauseSpeech(True) return gesture.send()
def script_executeCommand(self, gesture): if self.commandIndex < 0: ui.message(_("Select a command using up or down arrows")) return commandInfo = self.gestures[self.categories[self.catIndex]][ self.commands[self.commandIndex]] try: if commandInfo.className == "GlobalCommands": script = getattr(globalCommands.commands, "script_" + commandInfo.scriptName) elif commandInfo.className == "GlobalPlugin": i = [m.__module__ for m in globalPluginHandler.runningPlugins ].index(commandInfo.moduleName) script = getattr( list(globalPluginHandler.runningPlugins)[i], "script_" + commandInfo.scriptName) elif commandInfo.className == "AppModule": try: script = getattr(api.getForegroundObject().appModule, "script_" + commandInfo.scriptName) except: ui.message(_("Can't run this script here")) return else: self.finish() raise RuntimeError( "Failed to retrieve scripts. Not found in known modules.") except: self.finish() ui.message(_("Failed to retrieve scripts.")) raise try: g = inputCore._getGestureClsForIdentifier(commandInfo.gestures[0]) except: g = KeyboardInputGesture try: scriptHandler.executeScript(script, g) except: raise else: if gesture.modifierNames == [ "shift" ] or gesture.mainKeyName == "numpadPlus": speech.cancelSpeech() scriptHandler.executeScript(script, g) elif gesture.modifierNames == [ "control" ] or gesture.mainKeyName == "numpadMinus": speech.cancelSpeech() scriptHandler.executeScript(script, g) speech.cancelSpeech() scriptHandler.executeScript(script, g) if self.commands[self.commandIndex] not in self.recentCommands: key = self.commands[self.commandIndex] if commandInfo.className == "AppModule": key = "%s: %s" % (self.categories[self.catIndex], key) self.recentCommands[key] = commandInfo self.finish()
def executeScript(self, script): """ Executes the given script with this gesture, using scriptHandler.executeScript. This is only implemented so as to allow Gesture subclasses to perform an action directly before / after the script executes. """ return scriptHandler.executeScript(script, self)
def script_skipNextOutside(self, gesture): obj = self.nextOutsideObject while obj: if obj.isFocusable: api.setFocusObject(obj) if controlTypes.STATE_FOCUSED in obj.states: return # The object has received the focus correctly obj = obj.next # Has not been able to get out of the table if self.container.simpleParent.role == controlTypes.ROLE_DIALOG: # If we are in a dialogue, focus on the top panel api.setNavigatorObject(self.focusableContainer) scriptHandler.executeScript( globalCommands.commands.script_review_activate, None) pauseSpeech(True) return gesture.send()
def script_doAction(self, gesture): obj = api.getNavigatorObject() if obj.parent == self: if obj.actionCount > 0: x = int(obj.location.left + obj.location.width / 2) y = int(obj.location.top + obj.location.height / 2) winUser.setCursorPos(x, y) if api.getDesktopObject().objectFromPoint(x, y) == obj: if winUser.getKeyState(winUser.VK_LBUTTON) & 32768: winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None) winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 1, None, None) winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None) else: scriptHandler.executeScript(self.script_menu, None) else: beep(200, 80)
def script_nextEltRotor(self, gesture): if rotorItem == ROTOR_DEF: return self.sendComb('rightarrow', gesture) elif rotorItem in [ROTOR_MOVE, ROTOR_SELECT]: return self.sendComb(self.getCurrentSelectionRange(False), gesture) elif rotorItem == ROTOR_OBJ: self.sendComb('nvda+shift+rightarrow', gesture) self.showBrailleObj() elif rotorItem == ROTOR_REVIEW: scriptHandler.executeScript( globalCommands.commands.script_braille_scrollForward, gesture) elif rotorItem == ROTOR_TABLES: self.sendComb('control+alt+rightarrow', gesture) elif rotorItem == ROTOR_ERR: obj = api.getFocusObject() if obj.treeInterceptor is not None: obj.treeInterceptor.script_nextError(gesture) else: ui.message(_('Not supported here or browse mode not enabled')) else: return ui.message(_('Not implemented yet'))
def script_menu(self, gesture): obj = api.getNavigatorObject() if obj.parent == self and controlTypes.STATE_INVISIBLE not in obj.states: scriptHandler.executeScript( globalCommands.commands.script_moveMouseToNavigatorObject, None) pauseSpeech(True) x, y = winUser.getCursorPos() if x >= obj.location[0]: winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None, None) winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None, None) else: # TRANSLATORS: Message when it can't click in a item of the toolbar ui.message( _("Can't click in %s, try to maximize the window") % (obj.name if obj.name else controlTypes.roleLabels[obj.role])) else: beep(200, 80)
def script_extendedToggleW(self, gesture): executeScript(commands.script_toggleSpeakTypedWords, gesture) self.fetchSettings()
def script_extendedToggleC(self, gesture): executeScript(commands.script_toggleSpeakTypedCharacters, gesture) self.fetchSettings()
def _executeScript(self, script, gestureOrgestureCls, count): api.processPendingEvents() speech.cancelSpeech() for i in range(0, count + 1): speech.cancelSpeech() scriptHandler.executeScript(script, gestureOrgestureCls)
def onDevInfoButton(self, event): obj = self.getObjectFromList().obj api.setNavigatorObject(obj) scriptHandler.executeScript(globalCommands.commands.script_navigatorObject_devInfo, None)