def reportMediaStates(self):
     (muteState, level) = self.getVolumeMuteStateAndLevel()
     if not self.hasMedia():
         if muteState:
             # Translators: message to the user to say volume is muted.
             speech.speakMessage(_("volume muted"))
         return
     isPlaying = self.isPlaying()
     printDebug(
         "MainWindow: reportMediaStates playing= %s, oldPlaying= %s, mute = %s"
         % (isPlaying, self._curMediaState, muteState))
     if self._curMediaState is not None and (isPlaying
                                             == self._curMediaState):
         return
     if muteState:
         # Translators: message to user when volume is muted
         msg = _("volume muted")
         if isPlaying:
             # Translators: message to the user to say playing with muted volume.
             msg = _("Playing,%s") % msg
         else:
             # translators: message to the user to say pause with muted volume.
             msg = _("Pause,%s") % msg
         queueHandler.queueFunction(queueHandler.eventQueue,
                                    speech.speakMessage, msg)
     elif not isPlaying:
         # Translators: message to the user to say media is paused.
         speech.speakMessage(_("Pause"))
     self._curMediaState = isPlaying
 def script_makeChoice(
     self,
     gesture,
 ):
     printDebug("_makeChoice")
     stopScriptTimer()
     wx.CallAfter(ww_choice.ChoiceDialog.run, self)
 def event_foreground(self, obj, nextHandler):
     printDebug("word: event_foreground")
     if obj.windowClassName == "OpusApp":
         self.opusApp = obj
     if obj.windowClassName in ["_WwG"]:
         maximizeWindow(obj.windowHandle)
     nextHandler()
 def event_appModule_loseFocus(self):
     printDebug("Word: event_appModuleLoseFocus")
     self.hasFocus = False
     NVDAVersion = [version_year, version_major]
     if NVDAVersion >= [2019, 3]:
         from . import ww_automaticReading
         ww_automaticReading.terminate()
 def event_gainFocus(self, obj, nextHandler):
     printDebug(
         "Word: event_gainFocus: %s, %s" %
         (controlTypes.roleLabels.get(obj.role), obj.windowClassName))
     if not hasattr(self, "WinwordWindowObject"):
         try:
             self.WinwordWindowObject = obj.WinwordWindowObject
             self.WinwordVersion = obj.WinwordVersion
         except:  # noqa:E722
             pass
     if not self.hasFocus:
         nextHandler()
         return
     if obj.windowClassName == "OpusApp":
         # to suppress double announce of document window title
         return
     # for spelling and grammar check ending window
     if obj.role == controlTypes.ROLE_BUTTON and obj.name.lower() == "ok":
         foreground = api.getForegroundObject()
         if foreground.windowClassName == "#32770"\
          and foreground.name == "Microsoft Word":
             lastChild = foreground.getChild(foreground.childCount - 1)
             if lastChild.windowClassName == "MSOUNISTAT":
                 speech.speakMessage(foreground.description)
     nextHandler()
def _getActiveChild(obj):
	# QT doesn't do accFocus properly, so find the active child ourselves.
	if obj.childCount == 0:
		return None
	child = None
	oIA = obj.IAccessibleObject
	step = 1
	if obj.role == ROLE_TREEVIEW:
		step = getColumnHeaderCount(oIA)
		if step > 1 and obj.childCount > 20000:
			speech.speakMessage(_("Please wait"))
	for i in range(0, obj.childCount, step):
		if i > 20000\
			and obj.role in [ROLE_TREEVIEW, ROLE_LIST]:
			break
		oldChild = child
		child = oIA.accChild(i + 1)
		# my modification to remove an NVDA error
		if child is None:
			break
		try:
			states = child.accState(0)
		except Exception:
			continue
		if states & oleacc.STATE_SYSTEM_FOCUSED\
			or states & oleacc.STATE_SYSTEM_SELECTED:
			return obj.getChild(i)
		# 9202: In Virtualbox 5.2 and above, accNavigate is severely broken,
		# returning the current object when calling next, causing an endless loop.
		if oldChild == child:
			break
	printDebug("_getActiveChild end with no child:i= %s" % i)
	return None
Пример #7
0
	def script_resumePlayback(self, gesture):
		printDebug("resumePlayback")

		def callback(resumeTime):
			res = messageBox(
				# Translators: message to ask the user if he want to resume playback.
				_("Do you want to resume Playback at %s") % formatTime(resumeTime),
				# Translators: title of message box.
				makeAddonWindowTitle(_("Confirmation")),
				wx.OK | wx.CANCEL)
			if res == wx.CANCEL:
				return
			mainWindow = self.appModule.mainWindow
			totalTime = getTimeList(mainWindow.getTotalTime())
			jumpTime = getTimeList(resumeTime)
			wx.CallLater(
				200, mainWindow.jumpToTime, jumpTime, totalTime, startPlaying=True)

		if self.hasNoMedia():
			return
		from vlc_addonConfig import _addonConfigManager
		resumeTime = _addonConfigManager.getResumeFileTime()
		if resumeTime is None or resumeTime == 0:
			# Translators: message to user to say no resume time for this media
			ui.message(_("No resume time for this media"))
			return
		wx.CallAfter(callback, resumeTime)
Пример #8
0
	def event_foreground(self, obj, nextHandler):
		printDebug("appModule VLC: event_foreground: %s, %s" % (
			controlTypes.roleLabels.get(obj.role), obj.name))
		if not self.hasFocus:
			return
		wx.CallAfter(self.initAppModule)
		nextHandler()
Пример #9
0
 def sayText(self, wordDocument, reportColumnHeader=None):
     printDebug("cell setText: columnHeader= %s" % reportColumnHeader)
     headerText = ""
     reportTableHeadersFlag = config.conf['documentFormatting'][
         "reportTableHeaders"]  # noqa:E501
     if reportTableHeadersFlag:
         if reportColumnHeader is not None:
             headerText = wordDocument.fetchAssociatedHeaderCellText(
                 self.obj, reportColumnHeader)
             if headerText is not None:
                 ui.message(headerText)
         else:
             columnHeaderText = wordDocument.fetchAssociatedHeaderCellText(
                 self.obj, columnHeader=True)
             rowHeaderText = wordDocument.fetchAssociatedHeaderCellText(
                 self.obj, columnHeader=False)
             if rowHeaderText is not None:
                 ui.message(rowHeaderText)
             if columnHeaderText is not None:
                 ui.message(columnHeaderText)
     text = self.obj.Range.Text
     text = text[:-2]
     if text != "":
         ui.message(text)
     else:
         ui.message(_("empty"))
Пример #10
0
 def onActivate(self, evt):
     printDebug("collectInformation active: %s" % evt.GetActive())
     if evt.GetActive():
         self.isActive = True
     else:
         self.isActive = False
     evt.Skip()
Пример #11
0
	def __init__(self, parent, obj):
		printDebug("Collection init: rangeType = %s" % self.rangeType)
		Collection._instance = self
		self.wordApp = obj._get_WinwordApplicationObject()
		self.doc = self.wordApp.ActiveDocument
		self.selection = self.wordApp.Selection

		noElementMessages = {
			"focus": _("%s at cursor's position"),
			"selection": _("%s in the selection"),
			"document": _("%s in the document"),
			"page": _("%s in the page"),
			"startToFocus": _("%s between start of document and cursor's position"),
			"focusToEnd": _("%s between cursor's position and end of document")
			}

		(singular, plural) = self._name
		titles = {
			"focus": _("%s at cursor's position") % singular,
			"selection": _("%s in the selection") % plural,
			"document": _("%s in the document") % plural,
			"page": _("%s in the page") % plural,
			"startToFocus": _("%s between document's start and cursor's position") % plural,  # noqa:E501
			"focusToEnd": _("%s between cursor's position and document's end") % plural
				}

		self.noElementMessage = noElementMessages[self.rangeType] % self.noElement
		self.title = titles[self.rangeType]
		self.parent = parent
		self.collection = self.getElementsInCollection()
Пример #12
0
	def event_foreground(self):
		printDebug("VLCMainWindow: event_foreground")
		if not self.appModule._mainWindow:
			mainWindow = vlc_application.MainWindow(self.appModule)
			if mainWindow.topNVDAObject:
				self.appModule._mainWindow = mainWindow
				printDebug("VLCMainWindow: MainWindow set")
		super(VLCMainWindow, self).event_foreground()
Пример #13
0
	def terminate(self):
		printDebug("AppModule VLC: terminate")
		self.stopTaskTimer()
		if hasattr(self, "_oldInputCoreManagerCaptureFunc"):
			inputCore.manager._captureFunc = self._oldInputCoreManagerCaptureFunc
			del self._oldInputCoreManagerCaptureFunc
		self.resetStatusBar()
		super(AppModule, self).terminate()
 def script_insertComment(self, gesture):
     printDebug("insert comment")
     stopScriptTimer()
     winwordApplication = self._get_WinwordApplicationObject()
     if winwordApplication:
         wx.CallAfter(ww_comments.insertComment, winwordApplication)
     else:
         log.warning(" No winword application")
Пример #15
0
	def event_becomeNavigator(self, obj, nextHandler):
		printDebug("appModule VLC: event_becomeNavigator: %s, %s" % (controlTypes.roleLabels.get(obj.role), obj.description))  # noqa:E501
		if obj.description and "<html>" in obj.description:
			# Removes the HTML tags that appear in the
			# description of some objects
			while re.search("<[^(>.*<)]+>([^<]*</style>)?", obj.description):
				obj.description = obj.description.replace(
					re.search("<[^(>.*<)]+>([^<]*</style>)?", obj.description).group(), "")
		nextHandler()
 def __init__(self, mainPanel):
     printDebug("ControlPanel: init")
     super(ControlPanel, self).__init__()
     self.curControlIndex = 0
     if mainPanel.NVDAObject is None:
         return
     self.NVDAObject = mainPanel.NVDAObject.lastChild
     self.IAObject = self.NVDAObject.IAccessibleObject
     self.refreshControls()
	def initOverlayClass(self):
		self.bindGesture("kb:shift+f10", "application")
		printDebug("SettingSelectionTimerControlDigit initOverlayClass: name= %s, %s, childID= %s" % (
			self.name, roleLabels.get(self.role), self.IAccessibleChildID))
		from .au_applicationSettings import ApplicationSettingsManager
		applicationSettingsManager = ApplicationSettingsManager()
		self.editFormat = applicationSettingsManager.getSelectionFormat()
		tc = au_timerControl.TimerControl(self.parent, self.editFormat)
		self.editFormatID = tc.selectionFormatID
Пример #18
0
		def callback():
			time.sleep(0.2)
			o = api.getFocusObject()
			printDebug("appModule VLC inputCaptor callback: %s, hasFocus= %s" % (controlTypes.roleLabels.get(o.role), o.hasFocus))  # noqa:E501
			roles = [controlTypes.ROLE_MENU, controlTypes.ROLE_MENUITEM, ]
			if (o.role in roles and not o.hasFocus)\
				or o.role == controlTypes.ROLE_MENUBAR:
				printDebug("click foreground object when focus object is on not focused object")  # noqa:E501
				self.mainWindow.resetMediaStates()
				mouseClick(api.getForegroundObject(), True, True)
Пример #19
0
	def event_gainFocus(self, obj, nextHandler):
		printDebug("appModule VLC: event_gainFocus: role = %s, name = %s" % (
			controlTypes.roleLabels.get(obj.role), obj.name))
		if obj.description and "<html>" in obj.description:
			# Removes the HTML tags that appear in the description of some objects
			while re.search("<[^(>.*<)]+>([^<]*</style>)?", obj.description):
				obj.description = obj.description.replace(
					re.search("<[^(>.*<)]+>([^<]*</style>)?", obj.description).group(), "")
		nextHandler()
		self.lastFocusedObject = obj
Пример #20
0
	def goTo(self):
		printDebug("ReportDialog goTo")
		index = self.entriesList.GetFocusedItem()
		self.collection[index].goTo()
		wx.CallAfter(self.parent.Close)
		self.Close()
		speech.cancelSpeech()
		oldSpeechMode = speech.speechMode
		speech.speechMode = speech.speechMode_off
		core.callLater(500, self.collectionObject.speakContext, oldSpeechMode)
Пример #21
0
	def __init__(self, parent, collectionObject):
		printDebug("ReportDialog init: collectionObject = %s" % collectionObject)
		self.parent = parent
		super(ReportDialog, self).__init__(parent, title=collectionObject.title)
		self.timer = None
		self.collectionObject = collectionObject
		self.wordApp = collectionObject.wordApp
		self.collection = collectionObject.collection[:]
		self.initializeGUI()
		self.doGUI()
	def event_gainFocus(self):
		printDebug("TimerControlDigit event_gainFocus: %s, childID= %s" % (self.name, self.IAccessibleChildID))
		# When digit gains focus but not after script activation,
		# report audio position.
		tc = au_timerControl.TimerControl(self, self.editFormat)
		(sLabel, sTime) = tc.getLabelAndTime()
		try:
			msg = "%s %s" % (sLabel, au_time.getTimeMessage(sTime))
			ui.message(msg)
		except Exception:
			super(TimerControlDigit, self).event_gainFocus()
Пример #23
0
	def event_focusEntered(self, obj, nextHandler):
		printDebug("appModule VLC: event_focusEntered: %s, %s" % (
			controlTypes.roleLabels.get(obj.role), obj.name))
		if obj.role == controlTypes.ROLE_APPLICATION and obj.name == "vlc":
			try:
				self.mainWindow.resetMediaStates()
			except:  # noqa:E722
				pass
			return

		nextHandler()
Пример #24
0
	def reportElements(self):
		printDebug("Collection reportElement")
		col = self.collection
		if len(col) == 0:
			speech.speakMessage(self.noElementMessage)
			return
		if len(col) > 1:
			speech.speakMessage(_("{count} {element}") .format(
				count=len(col), element=self._name[0]))
		for element in col:
			element.reportText()
Пример #25
0
	def event_appModule_loseFocus(self):
		printDebug("appModule VLC: event_appModuleLoseFocus")
		api.setFocusObject = self.apiSetFocusObject
		self.resetStatusBar()
		self.stopTaskTimer()
		inputCore.manager._captureFunc = self._oldInputCoreManagerCaptureFunc
		del self._oldInputCoreManagerCaptureFunc
		if hasattr(self, "curAPIGetStatusBar"):
			api.getStatusBar = self.curAPIGetStatusBar
			delattr(self, "curAPIGetStatusBar")
		self.hasFocus = False
 def __init__(self, *args, **kwargs):
     printDebug("word appmodule init")
     super(AppModule, self).__init__(*args, **kwargs)
     # toggleDebugFlag()
     # configuration load
     self.hasFocus = False
     # install input gesture for recording autoreading voice profil
     NVDAVersion = [version_year, version_major]
     if NVDAVersion >= [2019, 3]:
         self.bindGesture("kb:windows+alt+f12", "setAutomaticReadingVoice")
     self.checkUseUIAForWord = True
Пример #27
0
	def event_appModule_gainFocus(self):
		printDebug("appModule VLC: event_appModulegainFocus")
		self.hasFocus = True
		self.lastFocusedObject = None
		self._oldInputCoreManagerCaptureFunc = inputCore.manager._captureFunc
		inputCore.manager._captureFunc = self._inputCaptor
		wx.CallAfter(self.initAppModule)
		if not hasattr(self, "apiSetFocusObject "):
			self.apiSetFocusObject = api.setFocusObject
			api.setFocusObject = mySetFocusObject
		self._mainWindow = None
		self._get_mainWindow()
	def event_gainFocus(self, obj, nextHandler):
		printDebug("audacity appModule event_gainFocus: name= %s, %s, childID= %s" % (
			obj.name, roleLabels.get(obj.role), obj.IAccessibleChildID))
		if self.trapGainFocus:
			api.setFocusObject(obj)
			self.trapGainFocus = False
			printDebug("audacity AppModule event_gainFocus trapped")
			return
		if self._reportFocusOnToolbar:
			self.reportFocusOnToolbar(obj)
			self._reportFocusOnToolbar = False
		nextHandler()
Пример #29
0
	def event_typedCharacter(self, obj, nextHandler, ch):
		printDebug("appModule VLC: event_typedCharacter: role = %s, name = %s, ch = %s (%s)" % (  # noqa:E501
			controlTypes.roleLabels.get(obj.role), obj.name, ch, ord(ch)))
		if not self.hasFocus:
			return
		if ord(ch) == 12:
			# after control+l command
			focus = api.getFocusObject()
			if hasattr(focus, "script_hideShowPlaylist"):
				focus.script_hideShowPlaylist(None)
				return
		nextHandler()
 def moveBy10Sec(count, direction):
     printDebug("MainWindow: moveBy10sec: count= %s, direction = %s" %
                (count, direction))
     keyToRight = self.vlcrcSettings.getKeyFromName("key-jump+short")
     keyToLeft = self.vlcrcSettings.getKeyFromName("key-jump-short")
     key = keyToRight if direction > 0 else keyToLeft
     d = 0
     if count:
         for i in range(1, count + 1):
             keyboardHandler.KeyboardInputGesture.fromName(key).send()
             d += direction * 10
     return d