Пример #1
0
 def chooseNVDAObjectOverlayClasses(self, obj, clsList):
     if obj.role == controlTypes.Role.APPLICATION:
         obj.parent = api.getDesktopObject()
         clsList.insert(0, VLC_application)
     if obj.windowClassName == u'Qt5QWindowIcon':
         if obj.role == controlTypes.Role.BORDER or obj.role == controlTypes.Role.PANE:
             if obj.childCount == 3:
                 if obj.lastChild.role == controlTypes.Role.STATICTEXT:
                     obj.role = controlTypes.Role.STATUSBAR
                     clsList.insert(0, VLC_StatusBar)
                 elif obj.lastChild and obj.lastChild.firstChild and obj.lastChild.firstChild.firstChild\
                 and obj.lastChild.firstChild.firstChild.role == controlTypes.Role.MENUBUTTON:
                     obj.role = controlTypes.Role.PANEL
                     #TRANSLATORS: Title of the panel that contains the playlist when it is inside main window
                     obj.name = _("Playlist")
                     obj.isPresentableFocusAncestor = False
                     clsList.insert(0, VLC_AnchoredPlaylist)
             else:
                 obj.role = controlTypes.Role.LAYEREDPANE
                 if obj.windowText in self.embeddedWindows:
                     obj.name = self.embeddedWindows[obj.windowText]
                 elif api.getForegroundObject() and api.getForegroundObject(
                 ).name and obj.windowText != api.getForegroundObject(
                 ).name:
                     obj.description = obj.windowText
                 clsList.insert(0, VLC_pane)
         elif obj.role == controlTypes.Role.WINDOW:
             if obj.firstChild and obj.firstChild.role == controlTypes.Role.MENUBAR:
                 clsList.insert(0, VLC_mainWindow)
             elif obj.windowStyle == 1442840576:
                 if obj.windowText in self.embeddedWindows:
                     obj.name = self.embeddedWindows[obj.windowText]
                     obj.isPresentableFocusAncestor = True
                 else:
                     obj.description = obj.windowText
                 clsList.insert(0, VLC_EmbeddedWindow)
         elif obj.windowStyle == -1764884480 and obj.isFocusable:
             try:
                 container = obj.container.container.container.container
             except AttributeError:
                 pass
             else:
                 if container and container.name and container.role == controlTypes.Role.LAYEREDPANE:
                     if obj.previous and obj.previous.role == controlTypes.Role.STATICTEXT:
                         obj.name = obj.previous.name
                     clsList.insert(0, VLC_mediaInfo)
     if obj.role == controlTypes.Role.SPINBUTTON:
         clsList.insert(0, VLC_spinButton)
     if obj.role == controlTypes.Role.DIALOG and (
             obj.windowClassName == u'Qt5QWindowToolSaveBits'
             or obj.windowClassName == u'Qt5QWindowIcon'):
         clsList.insert(0, VLC_Dialog)
     if obj.role == controlTypes.Role.LISTITEM and obj.windowText == u'StandardPLPanelClassWindow':
         clsList.insert(0, VLC_PlaylistItem)
     if obj.role == controlTypes.Role.EDITABLETEXT and (
             obj.windowClassName == u'Qt5QWindowIcon'
             or obj.simpleParent.role == 20):  #@ dev: add edit bookmarks
         # obj.typeBuffer = ""
         # obj.fakeCaret = len(obj.value)-1 if obj.value else 0
         clsList.insert(0, VLC_EditableText)
Пример #2
0
 def script_cycleWindows(self, gesture):
     if (api.getForegroundObject() and api.getForegroundObject().parent
             and hasattr(api.getForegroundObject().parent, "appModule")):
         topWindow = api.getForegroundObject().parent
         topWindowAppModule = api.getForegroundObject().parent.appModule
         if topWindowAppModule.appName == "explorer":
             # Translators: Information given when user tries to move to top-level window in Windows  Explorer
             ui.message(_("Not supported here."))
             return
         nextTopWin = prevTopWin = None
         if topWindow.simplePrevious and topWindow.simplePrevious.appModule == topWindowAppModule:
             prevTopWin = topWindow.simplePrevious
         if topWindow.simpleNext and topWindow.simpleNext.appModule == topWindowAppModule:
             nextTopWin = topWindow.simpleNext
         if not prevTopWin and not nextTopWin:
             # Translators: Announced when the current application has no top-level windows.
             ui.message(
                 _("This window has no top level windows to cycle to."))
             return
         elif prevTopWin and not nextTopWin:
             prevTopWin.setFocus()
         elif not prevTopWin and nextTopWin:
             nextTopWin.setFocus()
         else:
             # Translators: Announced when current program has multiple top-level windows.
             ui.message(_("Multiple top level windows detected."))
     else:
         # Translators: Reported when informations for the current window cannot be retrieved.
         ui.message(_("Can't retrieve window information for this object."))
         return
Пример #3
0
 def script_cc(self, gesture):
     global orig
     fg = api.getForegroundObject()
     try:
         handle = windowUtils.findDescendantWindow(
             fg.windowHandle, className="RichEdit20WPT", controlID=4100)
         if handle:
             # found handle
             w = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
                 handle, winUser.OBJID_CLIENT, 0)
             if scriptHandler.getLastScriptRepeatCount() == 2:
                 # trible press, copy to clipboard and set focus to original field
                 api.copyToClip(w.value)
                 ui.message(_("Copied to clipboard"))
                 api.setNavigatorObject(w, isFocus=True)
                 orig.setFocus()
             elif scriptHandler.getLastScriptRepeatCount() == 1:
                 # double press, set focus in field
                 winUser.setForegroundWindow(handle)
             else:
                 # single press
                 ui.message(" %s %s" % (w.name, w.value))
                 orig = api.getFocusObject()
     except LookupError:
         if api.getForegroundObject(
         ).appModule.productName == "Microsoft Outlook":
             tones.beep(440, 20)
         else:
             tones.beep(440, 20)
Пример #4
0
	def script_reportStatusLine(self, gesture):
		#it seems that the status bar is the last child of the forground object
		#so, get it from there
		obj = api.getForegroundObject().lastChild
		found=False
		if obj and obj.role == controlTypes.ROLE_STATUSBAR:
			text = api.getStatusBarText(obj)
			api.setNavigatorObject(obj)
			found=True
		else:
			info=api.getForegroundObject().flatReviewPosition
			if info:
				info.expand(textInfos.UNIT_STORY)
				info.collapse(True)
				info.expand(textInfos.UNIT_LINE)
				text=info.text
				info.collapse()
				api.setReviewPosition(info)
				found=True
		if not found:
			# Translators: Reported when there is no status line for the current program or window.
			ui.message(_("No status line found"))
			return
		if scriptHandler.getLastScriptRepeatCount()==0:
			ui.message(text)
		else:
			speech.speakSpelling(text)
Пример #5
0
 def script_mouseCursorInfo(self, gesture):
     if scriptHandler.getLastScriptRepeatCount() == 2:
         ui.message(
             _("Window in %d, %d. Width %d, height %d") %
             api.getForegroundObject().location)
         return
     if scriptHandler.getLastScriptRepeatCount() == 1:
         if not self.objectToDrag:
             ui.message(_("without selection for drag and drop"))
             return
         speech.speakObject(self.objectToDrag,
                            reason=controlTypes.REASON_MOUSE)
         ui.message(_(" marked for drag and drop"))
         x, y = self.dragFromPosition
         if api.getDesktopObject().objectFromPoint(x,
                                                   y) != self.objectToDrag:
             ui.message(_("(inaccessible from here)"))
         return
     fg = api.getForegroundObject()
     x, y = win32api.GetCursorPos()
     ui.message(_("Mouse cursor is on %d, %d above ") % (x, y))
     mouse = api.getDesktopObject().objectFromPoint(x, y)
     speech.speakObject(mouse, reason=controlTypes.REASON_MOUSE)
     if fg.appModule.appModuleName != mouse.appModule.appModuleName:
         ui.message(_("(outside of the active window)"))
     if winUser.getKeyState(winUser.VK_LBUTTON) & 32768:
         ui.message(_("Left button locked"))
     if winUser.getKeyState(winUser.VK_RBUTTON) & 32768:
         ui.message(_("Right button locked"))
     ui.message(_("%s cursor") % mouseHandler.curMouseShape)
Пример #6
0
 def elten_braille_thread(threadName=None):
     global stopThreads
     global eltenmod
     global eltenbraille
     global eltenbrailletext
     oldbraille = eltenbrailletext
     while (True):
         if (stopThreads): break
         time.sleep(0.1)
         if (eltenmod != None and eltenbraille != None):
             if (appModuleHandler.getAppModuleForNVDAObject(
                     api.getForegroundObject()) == eltenmod
                     and eltenbraille != None
                     and braille.handler.buffer != eltenbraille
                     and braille.handler.buffer !=
                     braille.handler.messageBuffer):
                 braille.handler.buffer = eltenbraille
                 braille.handler.update()
             elif (braille.handler != None
                   and appModuleHandler.getAppModuleForNVDAObject(
                       api.getForegroundObject()) != eltenmod
                   and braille.handler.buffer == eltenbraille):
                 braille.handler.buffer = braille.handler.mainBuffer
                 braille.handler.update()
             if oldbraille != eltenbrailletext:
                 oldbraille = eltenbrailletext
                 braille.handler.update()
Пример #7
0
def getNauStatusBarText() -> str:
	try:
		info = api.getForegroundObject().appModule.statusBarTextInfo
	except (NotImplementedError, AttributeError,):
		info = api.getForegroundObject().flatReviewPosition
		if info:
			info.expand(textInfos.UNIT_STORY)
			info.collapse(True)
			info.expand(textInfos.UNIT_LINE)
	if info:
		return info.text.strip()
	return ''
Пример #8
0
 def __init__(self, handle=None, windowTitle=None, appName=None):
     if handle:
         if winUser.isWindow(handle) == 0:
             raise ValueError(
                 "Cannot create object for non existing window")
         else:
             self.handle = handle
             self.windowTitle = windowTitle
             self.appName = appName
     else:
         self.handle = api.getForegroundObject().windowHandle
         self.windowTitle = api.getForegroundObject().name
         self.appName = appModuleHandler.getAppNameFromProcessID(
             api.getForegroundObject().processID, True)
Пример #9
0
	def event_UIA_notification(self, obj, nextHandler, displayString=None, **kwargs):
		# For some reason Cortana fires this event whenever user types and an answer is received.
		# Results are displayed inside a list.
		# Thus respond to both and see what should be announced.
		if displayString != "Cortana message received.": return
		# Version 1.1910 (beta) changed UIA tree for responses list.
		# 1.1911 (beta) and version 2 changed the tree yet again.
		# Thankfully, Cortana's response is part of a grouping object.
		# As long as conversation list uses the same UIA automation ID, traversal will work across versions (code credit: Abdel)
		clientObject = UIAHandler.handler.clientObject
		condition = clientObject.CreatePropertyCondition(UIAHandler.UIA_AutomationIdPropertyId, "ConversationList")
		cortanaWindow = clientObject.ElementFromHandleBuildCache(api.getForegroundObject().windowHandle, UIAHandler.handler.baseCacheRequest)
		# Instantiate UIA object directly.
		responses = UIA(UIAElement=cortanaWindow.FindFirstBuildCache(UIAHandler.TreeScope_Descendants, condition, UIAHandler.handler.baseCacheRequest))
		try:
			cortanaResponse = responses.children[-1]
			if cortanaResponse.name.startswith("Cortana") and cortanaResponse.simpleFirstChild.role == controlTypes.ROLE_GROUPING:
				cortanaResponse = cortanaResponse.simpleFirstChild.firstChild
				# When searching through Bing, summary text shows up.
				if cortanaResponse.childCount > 1:
					cortanaResponse = ", ".join([response.name for response in cortanaResponse.children])
				else: cortanaResponse = cortanaResponse.name
		except IndexError:
			cortanaResponse = ""
		if cortanaResponse != self._cortanaResponse:
			try:
				ui.message(cortanaResponse)
				self._cortanaResponse = cortanaResponse
			except (IndexError, TypeError):
				# IndexError deals with multi-part mesage, while TypeError deals with a list item with users's message on it. Skip them.
				pass
Пример #10
0
def doPreGainFocus(obj, sleepMode=False):
    oldForeground = api.getForegroundObject()
    oldFocus = api.getFocusObject()
    oldTreeInterceptor = oldFocus.treeInterceptor if oldFocus else None
    api.setFocusObject(obj)
    if globalVars.focusDifferenceLevel <= 1:
        newForeground = api.getDesktopObject().objectInForeground()
        if not newForeground:
            log.debugWarning(
                "Can not get real foreground, resorting to focus ancestors")
            ancestors = api.getFocusAncestors()
            if len(ancestors) > 1:
                newForeground = ancestors[1]
            else:
                newForeground = obj
        api.setForegroundObject(newForeground)
        executeEvent('foreground', newForeground)
    if sleepMode: return True
    #Fire focus entered events for all new ancestors of the focus if this is a gainFocus event
    for parent in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]:
        executeEvent("focusEntered", parent)
    if obj.treeInterceptor is not oldTreeInterceptor:
        if hasattr(oldTreeInterceptor, "event_treeInterceptor_loseFocus"):
            oldTreeInterceptor.event_treeInterceptor_loseFocus()
        if obj.treeInterceptor and obj.treeInterceptor.isReady and hasattr(
                obj.treeInterceptor, "event_treeInterceptor_gainFocus"):
            obj.treeInterceptor.event_treeInterceptor_gainFocus()
    return True
Пример #11
0
def getFile(folder, ext=""):
    obj = api.getForegroundObject()
    file = obj.name
    obj = api.getFocusObject()
    try:
        obj = obj.treeInterceptor.rootNVDAObject
        childID = obj.IAccessibleChildID
        iAObj = obj.IAccessibleObject
        accValue = iAObj.accValue(childID)
        nameToAdd = " - %s" % accValue.split("#")[0].split("/")[-1].split(
            "\\")[-1]
    except:
        nameToAdd = ""
    file = file.rsplit(" - ", 1)[0]
    file = file.split("\\")[-1]
    file += nameToAdd
    file = standardFileName(file)
    folderPath = os.path.join(PLACE_MARKERS_PATH, folder)
    maxLenFileName = 232 - len(folderPath)
    if maxLenFileName <= 0:
        return ""
    file = file[:maxLenFileName]
    file = file + ext
    path = os.path.join(folderPath, file)
    return path
 def script_addListWindow(self, gesture):
     self.openAPPListFile()
     for i in range(len(APPList)):
         text = APPList[i].strip("\n")
         fg = api.getForegroundObject()
         if fg.name == text:
             ui.message("이미 추가된 항목입니다.")
Пример #13
0
 def event_UIA_notification(self,
                            obj,
                            nextHandler,
                            displayString=None,
                            activityId=None,
                            **kwargs):
     # #12268: for "DisplayUpdated", announce display strings in braille and move on.
     if activityId == "DisplayUpdated":
         braille.handler.message(displayString)
     try:
         shouldAnnounceNotification = (obj.previous.UIAAutomationId
                                       in ("numberPad",
                                           "UnitConverterRootGrid"))
     except AttributeError:
         resultElement = api.getForegroundObject().children[1].lastChild
         # Redesigned in 2019 due to introduction of "always on top" i.e. compact overlay mode.
         if resultElement.UIAElement.cachedClassName != "LandmarkTarget":
             resultElement = resultElement.parent.children[1]
         shouldAnnounceNotification = (
             resultElement and resultElement.firstChild
             and resultElement.firstChild.UIAAutomationId
             not in noCalculatorEntryAnnouncements)
     # Display updated activity ID seen when entering calculations should be ignored
     # as as it is redundant if speak typed characters is on.
     if shouldAnnounceNotification or activityId != "DisplayUpdated":
         nextHandler()
 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 getCurrentFolder():
    oForeground = api.getForegroundObject()
    # for Office 2003 and dialogbox based on XP
    windowText = oForeground.windowText
    # Translators: this is title of classic Window to manage file.
    if windowText in [_("Open"), _("Save"), _("Save as"), _("Find in")]:
        if 'bosa_sdm_' in oForeground.windowClassName:
            oCurrentFolder = oForeground.children[14]
            path = oCurrentFolder.name
            folder = oCurrentFolder.value
            return (path, folder)
        elif '#32770' in oForeground.windowClassName:
            if oForeground.children[1].windowClassName == 'ComboBox':
                oCurrentFolder = oForeground.children[1]
                path = "%s\\%s" % (oCurrentFolder.name, oCurrentFolder.value)
                path = oCurrentFolder.name
                folder = oCurrentFolder.value
                return (path, folder)
    classNames = ("WorkerW", "ReBarWindow32", "Address Band Root",
                  "msctls_progress32", "Breadcrumb Parent", "ToolbarWindow32")
    o = oForeground
    for className in classNames:
        o = findChildObjectByClassName(o, className)
        if o is None:
            break
    if o is None:
        return None
    pathList = []
    for o in o.children:
        pathList.append(o.name)
    path = "\\".join(pathList[:-1])
    folder = pathList[-1]
    return (path, folder)
Пример #16
0
	def script_focusToSPLWindow(self, gesture):
		# Don't do anything if we're already focus on SPL Studio.
		if "splstudio" in api.getForegroundObject().appModule.appModuleName: return
		SPLHwnd = user32.FindWindowW(u"SPLStudio", None)
		if not SPLHwnd: ui.message(_("SPL Studio is not running."))
		# 17.01: SetForegroundWindow function is better, as there's no need to traverse top-level windows and allows users to "switch" to SPL window if the window is minimized.
		else: user32.SetForegroundWindow(user32.FindWindowW(u"TStudioForm", None))
Пример #17
0
 def script_reportRemaining(self, gesture):
     try:
         fg = api.getForegroundObject()
         s1 = fg.firstChild.next.next.firstChild.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.name
         ui.message(s1)
     except:
         pass
Пример #18
0
def obtainUWPWindowText():
    foreground = api.getForegroundObject()
    desktop = api.getDesktopObject()
    uwpTextList = [foreground.name]
    curObject = foreground.firstChild
    while curObject:
        if curObject.name is not None: uwpTextList.append(curObject.name)
        if curObject.simpleFirstChild:
            curObject = curObject.simpleFirstChild
            continue
        if curObject.simpleNext:
            curObject = curObject.simpleNext
            continue
        if curObject.simpleParent:
            parent = curObject.simpleParent
            # As long as one is on current foreground object...
            #Stay within the current top-level window.
            if parent.simpleParent == desktop:
                break
            while parent and not parent.simpleNext:
                parent = parent.simpleParent
            # But sometimes, the top-level window has no sibling at all (such is the case in Windows 10 Start menu).
            try:
                curObject = parent.simpleNext
            except AttributeError:
                continue
    return uwpTextList
Пример #19
0
	def event_UIA_notification(self, obj, nextHandler, displayString=None, activityId=None, **kwargs):
		# When no results shortcuts such as number row keys are pressed, display content will be announced.
		# #13383: it might be possible that the next command is a calculation shortcut such as S for sine.
		# Therefore, clear no result gestures flag from the app module while storing a copy of the flag here.
		# The event handler copy is used to handle the overall notification announcement later.
		doNotAnnounceCalculatorResults = self._noCalculatorResultsGesturePressed
		self._noCalculatorResultsGesturePressed = False
		calculatorVersion = int(self.productVersion.split(".")[0])
		# #12268: for "DisplayUpdated", announce display strings in braille  no matter what they are.
		# There are other activity Id's such as "MemorySlotAdded" and "MemoryCleared"
		# but they do not involve number entry.
		# Therefore, only handle the below activity Id.
		if activityId == "DisplayUpdated":
			braille.handler.message(displayString)
			resultElement = api.getForegroundObject().children[1].lastChild
			# Descend one more time in Windows 11 Calculator.
			if calculatorVersion >= 11:
				resultElement = resultElement.firstChild
			# Redesigned in 2019 due to introduction of "always on top" i.e. compact overlay mode.
			if resultElement.UIAElement.cachedClassName != "LandmarkTarget":
				resultElement = resultElement.parent.children[1]
			# Display string announcement is redundant if speak typed characters is on.
			if (
				resultElement
				and resultElement.firstChild
				and resultElement.firstChild.UIAAutomationId in noCalculatorEntryAnnouncements
				and doNotAnnounceCalculatorResults
			):
				return
		nextHandler()
Пример #20
0
 def script_voiceMessage(self, gesture):
     if self.recordConfig == "desactivado":
         gesture.send()
         return
     self.focusObj = api.getFocusObject()
     self.searchList()
     try:
         for obj in reversed(
                 api.getForegroundObject().children[1].children):
             if obj.UIAAutomationId == "btnVoiceMessage":
                 obj.doAction()
                 self.recordObj = obj
                 PlaySound("C:/Windows/Media/Windows Startup.wav",
                           SND_FILENAME | SND_ASYNC)
                 break
         self.focusObj.setFocus()
     except:
         pass
     try:
         if self.recordObj.next.UIAAutomationId != "ElapsedLabel":
             # Translators: Mensaje que indica el comienzo de la grabación
             message(_('grabando'))
         elif self.recordObj.next.UIAAutomationId == "ElapsedLabel":
             # Translators: Mensaje que indica el envío de la grabación
             message(_('Enviado'))
     except:
         pass
Пример #21
0
 def script_optionsMenu(self, gesture):
     obj = api.getForegroundObject().children[1].firstChild
     obj.doAction()
     message(obj.name)
     sleep(0.1)
     Thread(target=speak, args=(None, 0.4), daemon=True).start()
     Thread(target=self.tab, daemon=True).start()
Пример #22
0
 def __init__(self):
     self.handle = None
     fg = api.getForegroundObject()
     if fg and isinstance(fg.appModule, TotalCommanderAppModule):
         self.handle = ctypes.windll.user32.GetForegroundWindow()
         if self.handle and self.currentPanel() <= 0:
             self.handle = None
Пример #23
0
 def _update_Toolbars(self, callback=0):
     global toolBars
     obj = api.getForegroundObject()
     if not obj or obj.name == None:
         try:
             obj = api.getFocusAncestors()[2]
         except:
             obj = api.getFocusObject().parent.parent.parent
     if not obj:
         return
     winHandle = obj.windowHandle
     winClass = obj.windowClassName
     if winHandle in toolBars:
         return True
     else:
         activeToolBars = {
             tb.name.lstrip('Audacity ').rstrip('Toolbar'): tb
             for tb in obj.recursiveDescendants
             if tb.role == controlTypes.ROLE_TOOLBAR
         }
         if bool(len(activeToolBars)):
             toolBars[winHandle] = activeToolBars
             return True
         elif callback != 1:
             self._update_Toolbars(1)
         else:
             return
Пример #24
0
def getSmartName():
    """
        On vérifie que le plugin est pris en charge par LBL, et si tel est le cas, on retourne son nom de manière intelligible
    """

    window = api.getForegroundObject()
    fxName = getSelectedFXName()

    if "SSDSampler" in fxName:
        return "Steeven Slate Drum 5"
    elif "DSK Saxophones" in fxName:
        return "DSK Saxophones"
    elif "EZdrummer" in fxName:
        return "EZ Drummer"
    elif "GTune" in fxName:
        return "GTune"
    elif "sforzando" in fxName:
        return "Sforzando"
    elif "Guitar Rig" in fxName:
        return "Guitar Rig"
    elif "Zampler" in fxName:
        return "Zampler"
    elif "VSCO2" in fxName:
        return "VSCO2"
    elif "Addictive Drums" in fxName:
        return "Addictive Drums"
    elif "Addictive Keys" in fxName:
        return "Addictive Keys"
    return
Пример #25
0
 def getDocName(self):
     # getting file path and name
     global docPath
     docPath = ""
     fg = api.getForegroundObject()
     # We check if we are in the Windows Explorer.
     if fg.role != api.controlTypes.Role.PANE and fg.appModule.appName != "explorer":
         return
     shell = COMCreate("shell.application")
     # We go through the list of open Windows Explorers to find the one that has the focus.
     for window in shell.Windows():
         try:
             if window.hwnd and window.hwnd == fg.windowHandle:
                 focusedItem = window.Document.FocusedItem
                 break
         except:
             pass
     else:  # loop exhausted
         desktop_path = os.path.join(
             os.path.join(os.environ['USERPROFILE']), 'Desktop')
         docPath = '\"' + desktop_path + '\\' + api.getDesktopObject(
         ).objectWithFocus().name + '\"'
         return
     # Now that we have the current folder, we can explore the SelectedItems collection.
     targetFile = focusedItem.path
     docPath = '\"' + str(targetFile) + '\"'
Пример #26
0
 def script_reportCrossfade(self, gesture):
     try:
         fg = api.getForegroundObject()
         s1 = fg.firstChild.next.next.firstChild.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.next.description
         ui.message(s1)
     except:
         pass
Пример #27
0
 def script_attachments(self, gesture):
     fg = api.getForegroundObject()
     try:
         obj = api.getFocusObject()
         appName = obj.appModule.productName
         appVersion = obj.appModule.productVersion
         if appVersion.startswith('15.'):
             ui.message(
                 "use tab or shift-tab to go to the attachments in Outlook 2013"
             )
             tones.beep(440, 20)
             return
         handle = windowUtils.findDescendantWindow(
             fg.windowHandle, className="rctrl_renwnd32", controlID=4306)
         if handle:
             # found handle
             w = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
                 handle, winUser.OBJID_CLIENT, 0)
             try:
                 wc = w.firstChild.firstChild.firstChild.firstChild.childCount
                 indexString = (" %s " % (wc))
                 children = w.firstChild.firstChild.firstChild.firstChild.children
                 for child in children:
                     ui.message(child.name)
             except:
                 indexString = 0
                 pass
             if scriptHandler.getLastScriptRepeatCount() == 1:
                 # double press, set focus in field
                 winUser.setForegroundWindow(handle)
             else:
                 # single press
                 ui.message(" %s %s" % (w.name, indexString))
     except LookupError:
         tones.beep(440, 20)
Пример #28
0
 def script_speakInfo(self, gesture):
     try:
         fg = api.getForegroundObject()
         s2 = fg.firstChild.next.next.next.next.next.firstChild.next.name
         s3 = fg.firstChild.next.next.next.next.next.firstChild.next.next.next.next.next.name
         s4 = fg.firstChild.next.next.next.next.next.firstChild.next.next.next.next.next.next.name
         s7 = fg.firstChild.next.next.next.next.next.firstChild.next.next.next.next.next.next.next.next.next.name
         s8 = fg.firstChild.next.next.next.next.next.firstChild.next.next.next.next.next.next.next.next.next.next.name
         if not s8: s7 = ""
         s5 = fg.firstChild.next.next.next.next.next.firstChild.next.next.next.next.next.next.next.next.next.next.next.next.next.name
         s6 = fg.firstChild.next.next.next.next.next.firstChild.next.next.next.next.next.next.next.next.next.next.next.next.next.next.name
         infoString = (" %s %s %s %s %s %s %s" %
                       (s2, s3, s4, s7, s8, s5, s6))
         infoString2 = (" %s %s %s %s %s %s %s" %
                        (s2, s3, s4, s7, s8, s5, s6))
         #infoString2 = s2+" - "+s4+" - "+s6
         infoString3 = ("%s %s %s %s %s %s" % (s3, s4, s7, s8, s5, s6))
         #infoString3 = s4+" - "+s6
         if scriptHandler.getLastScriptRepeatCount() == 1:
             #double press
             api.copyToClip(infoString3)
             tones.beep(1500, 120)
         else:
             num = int(gesture.mainKeyName[-1])
             if num == 2:
                 if not s6: s6 = "no song information found!"
                 if not s4: s4 = "no station information found!"
                 ui.browseableMessage(infoString2,
                                      title="Now playing on " + s4,
                                      isHtml=False)
             else:
                 ui.message(infoString)
     except AttributeError:
         pass
 def mos():
     f = api.getForegroundObject()
     try:
         obj = f.children[1].children[2].children[0].children[
             0].children[0]
     except:
         obj = f.children[1].children[0].children[2].children[
             0].children[0].children[0]
     c_obj = obj.name
     a = c_obj.replace('Dirección: ', '')
     #d=os.path.dirname(a)
     #b=os.path.basename(a)
     os.chdir(a)
     try:
         os.environ['PROGRAMFILES(X86)']
         with disable_file_system_redirection():
             subprocess.Popen('attrib /d -h', shell=True)
             #ejecutar(None,'cmd.exe','/c' + 'attrib /d /s -h', None, 10)
             os.chdir(a_path)
             winsound.Beep(300, 300)
     except:
         #ejecutar('runas','cmd.exe','/c' + 'attrib /d -h', None, 10)
         subprocess.Popen("attrib /d -h", shell=True)
         os.chdir(a_path)
         winsound.Beep(300, 300)
Пример #30
0
def doPreGainFocus(obj,sleepMode=False):
	oldForeground=api.getForegroundObject()
	oldFocus=api.getFocusObject()
	oldTreeInterceptor=oldFocus.treeInterceptor if oldFocus else None
	api.setFocusObject(obj)
	if globalVars.focusDifferenceLevel<=1:
		newForeground=api.getDesktopObject().objectInForeground()
		if not newForeground:
			log.debugWarning("Can not get real foreground, resorting to focus ancestors")
			ancestors=api.getFocusAncestors()
			if len(ancestors)>1:
				newForeground=ancestors[1]
			else:
				newForeground=obj
		api.setForegroundObject(newForeground)
		executeEvent('foreground',newForeground)
	if sleepMode: return True
	#Fire focus entered events for all new ancestors of the focus if this is a gainFocus event
	for parent in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]:
		executeEvent("focusEntered",parent)
	if obj.treeInterceptor is not oldTreeInterceptor:
		if hasattr(oldTreeInterceptor,"event_treeInterceptor_loseFocus"):
			oldTreeInterceptor.event_treeInterceptor_loseFocus()
		if obj.treeInterceptor and obj.treeInterceptor.isReady and hasattr(obj.treeInterceptor,"event_treeInterceptor_gainFocus"):
			obj.treeInterceptor.event_treeInterceptor_gainFocus()
	return True
Пример #31
0
 def inMainWindow(self):
     try:
         if api.getForegroundObject().IA2Attributes["id"] != "main-window":
             return False
     except (AttributeError, KeyError):
         return False
     return True
Пример #32
0
 def searchObject(self, path):
     obj = api.getForegroundObject()
     for milestone in path:
         obj = self.searchAmongTheChildren(milestone, obj)
         if not obj:
             return
     return obj
Пример #33
0
	def event_gainFocus(self,obj,nextHandler):
		if obj.windowClassName=="DirectUIHWND" and obj.role==controlTypes.ROLE_BUTTON and not obj.next:
			prev=obj.previous
			if prev and prev.role==controlTypes.ROLE_STATICTEXT:
				# This is for a popup message in the logon dialog.
				# Present the dialog again so the message will be reported.
				speech.speakObjectProperties(api.getForegroundObject(),name=True,role=True,description=True)
				braille.invalidateCachedFocusAncestors(1)
		nextHandler()
Пример #34
0
	def script_reportCommentsWindow(self,gesture):
		obj = fetchObject(api.getForegroundObject(), [2, 0, 1, 0, 1, 0, 1, 0])
		# if it isnt in the normal location, try to find it in the
		# location of the automatic window.
		if not obj: 
			obj = fetchObject(api.getForegroundObject(), [2, 0, 1, 0, 1, 0, 0, 0])
		if obj and obj.windowControlID == 105:
			try:
				ui.message(obj.name + " " + obj.value)
			except:
				# Translators: this message is reported when there are no
				# comments to be presented to the user in the translator
				# comments window in poedit.
				ui.message(_("No comment."))
		else:
			# Translators: this message is reported when NVDA is unable to find
			# the 'comments' window in poedit.
			ui.message(_("Could not find comment window."))
Пример #35
0
	def script_reportParameterInfo(self, gesture):
		# get the parameter info object
		try:
			obj = api.getForegroundObject().firstChild.firstChild
		except:
			return
		if obj.role == controlTypes.ROLE_TOOLTIP:
			# emulate an alert event for this object
			eventHandler.queueEvent("alert", obj)
Пример #36
0
	def script_connect(self, gesture):
		# Same as SAM's connection routine, but this time, keep an eye on self.name and a different connection flag.
		connectButton = api.getForegroundObject().children[2]
		if connectButton.name == "Disconnect": return
		ui.message(_("Connecting..."))
		# Juggle the focus around.
		connectButton.doAction()
		self.setFocus()
		# Same as SAM encoders.
		if not self.backgroundMonitor: self.connectStart(connecting=True)
Пример #37
0
	def script_onLocationChange(self, gesture):
		gesture.send()
		#get the location from the status bar
		obj = api.getForegroundObject().lastChild
		text = obj.children[2].name
		x = re.match(REG_SPLIT_LOCATION_TEXT, text).group(1)
		y = re.match(REG_SPLIT_LOCATION_TEXT, text).group(2)
		#translators: the x coord and the y coord of a UI element in windows forms designer
		msg = _("X: %s  y: %s" %(x, y))
		ui.message(msg)
Пример #38
0
	def script_onSizeChange(self, gesture):
		gesture.send()
		#get the position from the status bar
		obj = api.getForegroundObject().lastChild
		text = obj.children[2].name
		width = re.match(REG_SPLIT_LOCATION_TEXT, text).group(3)
		hight = re.match(REG_SPLIT_LOCATION_TEXT, text).group(4)
		#translators: the width and the hight of a UI element in windows forms designer
		msg = _("width: %s  hight: %s" %(width, hight))
		ui.message(msg)
Пример #39
0
	def _get_statusBars(self, statBarIndex, refill=False):
		global multiInstance
		# In case multiple instances of GoldWave are running, flush the status bar cache.
		index = 0
		if refill or multiInstance > 1 or not len(self.statusBarCache):
			for child in api.getForegroundObject().children:
				if child.role == ROLE_STATUSBAR:
					if not child.displayText: child.redraw()
					self.statusBarCache[index] = child
					index+=1
		return self.statusBarCache[statBarIndex]
Пример #40
0
	def script_nextPageTab (self,gesture):
		if api.getFocusObject().windowText == u'DropboxTrayIcon' or api.getFocusObject().windowClassName == u'#32768' or api.getForegroundObject().name != _("Dropbox Preferences"):
			gesture.send()
			return
		tabPage = api.getForegroundObject().simpleFirstChild
		tabPageHandle = tabPage.windowHandle
		changePageTab(tabPageHandle,"next")
		objToFocus = tabPage.simpleNext
		while objToFocus.isFocusable == False or objToFocus.role == controlTypes.ROLE_GROUPING:
			objToFocus = objToFocus.simpleNext
		objToFocus.setFocus()
Пример #41
0
	def script_SPLControllerPrefix(self, gesture):
		global SPLWin
		# Error checks:
		# 1. If SPL Studio is not running, print an error message.
		# 2. If we're already  in SPL, ask the app module if SPL Assistant can be invoked with this command.
		if "splstudio" in api.getForegroundObject().appModule.appModuleName:
			if not api.getForegroundObject().appModule.SPLConPassthrough():
				# Translators: Presented when NVDA cannot enter SPL Controller layer since SPL Studio is focused.
				ui.message(_("You are already in SPL Studio window. For status commands, use SPL Assistant commands."))
				self.finish()
				return
			else:
				api.getForegroundObject().appModule.script_SPLAssistantToggle(gesture)
				return
		SPLWin = user32.FindWindowW(u"SPLStudio", None)
		if SPLWin == 0:
			# Translators: Presented when Station Playlist Studio is not running.
			ui.message(_("SPL Studio is not running."))
			self.finish()
			return
		# No errors, so continue.
		if not self.SPLController:
			self.bindGestures(self.__SPLControllerGestures)
			# 17.12: also bind cart keys.
			# Exclude number row if Studio Standard is running.
			cartKeys = self.fnCartKeys
			if not getNVDAObjectFromEvent(user32.FindWindowW(u"TStudioForm", None), OBJID_CLIENT, 0).name.startswith("StationPlaylist Studio Standard"):
				cartKeys+=self.numCartKeys
			for cart in cartKeys:
				self.bindGesture("kb:%s"%cart, "cartsWithoutBorders")
				self.bindGesture("kb:shift+%s"%cart, "cartsWithoutBorders")
				self.bindGesture("kb:control+%s"%cart, "cartsWithoutBorders")
				self.bindGesture("kb:alt+%s"%cart, "cartsWithoutBorders")
			self.SPLController = True
			# Translators: The name of a layer command set for Station Playlist Studio.
			# Hint: it is better to translate it as "SPL Control Panel."
			ui.message(_("SPL Controller"))
		else:
			self.script_error(gesture)
			self.finish()
	def readTrainingText(self):
		window = api.getForegroundObject()
		for descendant in window.recursiveDescendants:
			if not isinstance(descendant, UIA):
				continue
			try:
				automationID = descendant.UIAElement.currentAutomationID
			except:
				continue
			if automationID == "txttrain":
				api.setNavigatorObject(descendant)
				ui.message(descendant.name)
				break
Пример #43
0
	def event_NVDAObject_init(self, obj):
		if obj.name == "Active Files" and obj.role in (controlTypes.ROLE_DIALOG, controlTypes.ROLE_LIST):
			#this object reports the descktop object as its parent, this causes 2 issues 
			#redundent announcement of the foreground object 
			#and losing the real foreground object which makes reporting the status bar script not reliable, which is crootial for breakpoint reporting to work.
			obj.role = controlTypes.ROLE_LIST
			parent = obj.parent
			if isinstance(parent, Desktop):
				obj.parent = api.getForegroundObject()
			#description here also is redundant, so, remove it
			obj.description = ""
		elif obj.windowClassName == "ToolWindowSelectAccList":
			#all objects with this window class name have a description which is identical to the name
			#don't think that someone is interested to hear it
			obj.description = ""
Пример #44
0
	def script_title(self,gesture):
		obj=api.getForegroundObject()
		title=obj.name
		if not isinstance(title,basestring) or not title or title.isspace():
			title=obj.appModule.appName  if obj.appModule else None
			if not isinstance(title,basestring) or not title or title.isspace():
				title=_("no title")
		repeatCount=scriptHandler.getLastScriptRepeatCount()
		if repeatCount==0:
			ui.message(title)
		elif repeatCount==1:
			speech.speakSpelling(title)
		else:
			if api.copyToClip(title):
				ui.message(_("%s copied to clipboard")%title)
Пример #45
0
	def _isCompletionPopupShowing(self):
		obj = api.getForegroundObject()
		try:
			if obj.firstChild.firstChild.firstChild.next.next.role == controlTypes.ROLE_POPUPMENU:
				return True
		except Exception as e:
			pass
		try:
			obj1 = obj .firstChild
			obj2 = obj1.firstChild
			if obj1.role == controlTypes.ROLE_WINDOW and obj1.name == ''\
			and obj2.role == controlTypes.ROLE_WINDOW and obj2.name == '':
				return True
		except Exception as e:
			pass
		return False
Пример #46
0
	def updateNamespaceSnapshotVars(self):
		"""Update the console namespace with a snapshot of NVDA's current state.
		This creates/updates variables for the current focus, navigator object, etc.
		"""
		self._namespaceSnapshotVars = {
			"focus": api.getFocusObject(),
			# Copy the focus ancestor list, as it gets mutated once it is replaced in api.setFocusObject.
			"focusAnc": list(api.getFocusAncestors()),
			"fdl": api.getFocusDifferenceLevel(),
			"fg": api.getForegroundObject(),
			"nav": api.getNavigatorObject(),
			"review":api.getReviewPosition(),
			"mouse": api.getMouseObject(),
			"brlRegions": braille.handler.buffer.regions,
		}
		self.namespace.update(self._namespaceSnapshotVars)
Пример #47
0
	def script_reportAutoCommentsWindow(self,gesture):
		obj = fetchObject(api.getForegroundObject(), [2, 0, 1, 0, 1, 0, 0, 0])
		# check the controlid, because in certain situations 
		# autoComments and comment windows change places.
		if obj and obj.windowControlID == 102:
			try:
				ui.message(obj.name + " " + obj.value)
			except:
				# Translators: this message is reported when there are no 
				# comments to be presented to the user in the automatic 
				# comments window in poedit.
				ui.message(_("No automatic comments."))
		else:
			# Translators: this message is reported when NVDA is unable to find 
			# the 'automatic comments' window in poedit.
			ui.message(_("Could not find automatic comments window."))
Пример #48
0
	def script_clickButtonCancel (self,gesture):
		# Translators: the title of the dropbox preferences dialog, it is important to have the same capitalization/spelling as in the dropbox gui. If Dropbox hasn't been translated to your language yet, leave this blank or write the original text.
		if api.getFocusObject().windowText == u'DropboxTrayIcon' or api.getFocusObject().windowClassName == u'#32768' or api.getForegroundObject().name != _("Dropbox Preferences"):
			gesture.send()
			return
		cancelButton=api.getForegroundObject().simpleLastChild
		# Translators: the name of the dropbox preferences cancel button, it is important to have the same capitalization/spelling as in the dropbox gui. If Dropbox hasn't been translated to your language yet, leave this blank or write the original text.
		if cancelButton.name != _('Cancel'):
			cancelButton=cancelButton.simplePrevious if cancelButton.simplePrevious.name == _('Cancel') else None
		if cancelButton == None:
			ui.message(_("Cancel button not found"))
			gesture.send()
		else:
			(x,y,l,h) = cancelButton.IAccessibleObject.accLocation (0)
			winUser.setCursorPos (x,y)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
			winUser.mouse_event (winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
Пример #49
0
	def script_reportCommentsWindow(self,gesture):
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(api.getForegroundObject().windowHandle, visible=True, controlID=104),
				winUser.OBJID_CLIENT, 0)
		except LookupError:
			# Translators: this message is reported when NVDA is unable to find
			# the 'comments' window in poedit.
			ui.message(_("Could not find comment window."))
			return None
		try:
			ui.message(obj.name + " " + obj.value)
		except:
			# Translators: this message is reported when there are no
			# comments to be presented to the user in the translator
			# comments window in poedit.
			ui.message(_("No comment."))
Пример #50
0
def _getCurLineNumber():
	"""gets current line number which has the caret in the editor based on status bar text"""
	obj = api.getForegroundObject().lastChild
	text = None
	if obj and obj.role == controlTypes.ROLE_STATUSBAR:
		text = api.getStatusBarText(obj)
	if not text:
		return 0
	try:
		lineInfo = re.search(REG_GET_LINE_TEXT, text).group()
	except:
		return 0
	try:
		lineNum = int(re.search(REG_GET_LINE_NUM, lineInfo).group())
	except:
		return 0
	if lineNum <= 0:
		return 0
	return lineNum
Пример #51
0
	def script_reportAutoCommentsWindow(self,gesture):
		obj = fetchObject(api.getForegroundObject(), [2, 0, 1, 0, 1, 0, 1])
		if obj and obj.windowControlID != 101:
			try:
				obj = obj.next.firstChild
			except AttributeError:
				obj = None
		elif obj:
			obj = obj.firstChild
		if obj:
			try:
				ui.message(obj.name + " " + obj.value)
			except:
				# Translators: this message is reported when there are no 
				# notes for translators to be presented to the user in Poedit.
				ui.message(_("No notes for translators."))
		else:
			# Translators: this message is reported when NVDA is unable to find 
			# the 'Notes for translators' window in poedit.
			ui.message(_("Could not find Notes for translators window."))
Пример #52
0
def getFile(folder, ext=""):
	obj=api.getForegroundObject()
	file = obj.name
	obj = api.getFocusObject()
	try:
		obj = obj.treeInterceptor.rootNVDAObject
		childID = obj.IAccessibleChildID
		iAObj = obj.IAccessibleObject
		accValue = iAObj.accValue(childID)
		nameToAdd = " - %s" % accValue.split("#")[0].split("/")[-1].split("\\")[-1]
	except:
		nameToAdd = ""
	file = file.rsplit(" - ", 1)[0]
	file = file.split("\\")[-1]
	file += nameToAdd
	file = standardFileName(file)
	folderPath = os.path.join(PLACE_MARKERS_PATH, folder)
	maxLenFileName = 232-len(folderPath)
	if maxLenFileName <= 0:
		return ""
	file = file[:maxLenFileName]
	file = file+ext
	path = os.path.join(folderPath, file)
	return path
Пример #53
0
	def event_suggestionsClosed(self):
		# Until this problem is fixed, treat Sets search field with contempt and transform this into a suggestions open event.
		if self.appModule != api.getForegroundObject().appModule:
			super(SetsSearchField, self).event_suggestionsOpened()
			return
		super(SetsSearchField, self).event_suggestionsOpened()
Пример #54
0
	def script_treeSpy(self, gesture):
		# Get the foreground object
		fg = api.getForegroundObject()
		activate(fg)
Пример #55
0
	def script_speakForeground(self,gesture):
		obj=api.getForegroundObject()
		if obj:
			speech.speakObject(obj,reason=speech.REASON_QUERY)
			obj.speakDescendantObjects()
Пример #56
0
	def script_sayPageTabActive(self,gesture):
		if api.getFocusObject().windowText == u'DropboxTrayIcon' or api.getFocusObject().windowClassName == u'#32768' or api.getForegroundObject().name != _("Dropbox Preferences"):
			gesture.send()
			return
		tabPageHandle = api.getForegroundObject().simpleFirstChild.windowHandle
		ui.message(getPageTabActive(tabPageHandle))