Example #1
0
 def checkSearchEditComboBoxDisplay(self, setFocus=False):
     # check if  search edit combo box is shown.
     # If Not press "expand" buttonto show it.
     obj = findWindowNVDAObject("searchCombo")
     if obj is None or not winUser.isWindowVisible(obj.windowHandle):
         clickButton("expandButton")
         time.sleep(1.0)
         obj = findWindowNVDAObject("searchCombo")
         if obj is None or not winUser.isWindowVisible(obj.windowHandle):
             # impossible to display search edit box
             ui.message(_("Search edit box not found"))
             return False
     if setFocus:
         comboBox = self._getSearchEditComboBoxObject()
         comboBox.setFocus()
     return True
Example #2
0
	def __init__(self):
		style = wx.DEFAULT_FRAME_STYLE ^ wx.MAXIMIZE_BOX ^ wx.MINIMIZE_BOX | wx.FRAME_NO_TASKBAR
		super(MainFrame, self).__init__(None, wx.ID_ANY, versionInfo.name, size=(1,1), style=style)
		self.Bind(wx.EVT_CLOSE, self.onExitCommand)
		self.sysTrayIcon = SysTrayIcon(self)
		#: The focus before the last popup or C{None} if unknown.
		#: This is only valid before L{prePopup} is called,
		#: so it should be used as early as possible in any popup that needs it.
		#: @type: L{NVDAObject}
		self.prevFocus = None
		#: The focus ancestors before the last popup or C{None} if unknown.
		#: @type: list of L{NVDAObject}
		self.prevFocusAncestors = None
		# If NVDA has the uiAccess privilege, it can always set the foreground window.
		import systemUtils
		if not systemUtils.hasUiAccess():
			# This makes Windows return to the previous foreground window and also seems to allow NVDA to be brought to the foreground.
			self.Show()
			self.Hide()
			if winUser.isWindowVisible(self.Handle):
				# HACK: Work around a wx bug where Hide() doesn't actually hide the window,
				# but IsShown() returns False and Hide() again doesn't fix it.
				# This seems to happen if the call takes too long.
				self.Show()
				self.Hide()
Example #3
0
 def script_clickExpandButton(self, gesture):
     if not self.inMainWindow():
         gesture.send()
         return
     focus = api.getFocusObject()
     if getControlID(focus.windowHandle) in [
             ctrlIdsDic["stationsList"], ctrlIdsDic["searchEdit"]
     ]:
         # focus in search edit box or stations list, we can't stay here
         name = clickButton("expandButton")
     else:
         name = clickButtonWithoutMoving("expandButton")
     if name:
         ui.message(name)
         # say if stations list is visible or not.
         time.sleep(1.0)
         h = findWindowNVDAObject("stationsList").windowHandle
         if not h or not winUser.isWindowVisible(h):
             ui.message(
                 _("Search edit box and Stations list are not more visible")
             )
             obj = api.getFocusObject()
         else:
             # now set focus on stations list
             obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(h, -4, 0)
             obj.setFocus()
         eventHandler.queueEvent("gainFocus", obj)
Example #4
0
def findGroupboxObject(obj):
    prevWindow = winUser.getPreviousWindow(obj.windowHandle)
    while prevWindow:
        if (winUser.getClassName(prevWindow) == "Button"
                and winUser.getWindowStyle(prevWindow) & winUser.BS_GROUPBOX
                and winUser.isWindowVisible(prevWindow)):
            groupObj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
                prevWindow, winUser.OBJID_CLIENT, 0)
            try:
                (left, top, width, height) = obj.location
                (groupLeft, groupTop, groupWidth,
                 groupHeight) = groupObj.location
            except:  # noqa: E722 Bare except
                return
            if (groupObj.IAccessibleRole == oleacc.ROLE_SYSTEM_GROUPING
                    and left >= groupLeft and (left + width) <=
                (groupLeft + groupWidth) and top >= groupTop
                    and (top + height) <= (groupTop + groupHeight)):
                return groupObj
        tempWindow = winUser.getPreviousWindow(prevWindow)
        if tempWindow == prevWindow:
            # In rare cases (e.g. HWND 65554 "Message"), getPreviousWindow can return
            # the window passed to it, causing an infinite loop.
            break
        prevWindow = tempWindow
Example #5
0
def isRealWindow(hWnd):
	name = winUser.getWindowText(hWnd)
	visible = winUser.isWindowVisible(hWnd)
	lExStyle = getExtendedWindowStyle(hWnd)
	isToolWindow = (lExStyle & WS_EX_TOOLWINDOW) == 0
	isAppWindow = (lExStyle & WS_EX_APPWINDOW) == 0
	hasOwner = winUser.getWindow(hWnd, winUser.GW_OWNER)
	if not winUser.isWindowVisible(hWnd):
		return False
	if getParent(hWnd):
		return False
	if (isToolWindow and not hasOwner) or (
		(isAppWindow and hasOwner)):
		if winUser.getWindowText(hWnd):
			return True
	return False
Example #6
0
 def callback(window, data):
     if ((visible is None or winUser.isWindowVisible(window) == visible) and
         (not controlID or winUser.getControlID(window) == controlID) and
         (not className or winUser.getClassName(window) == className)):
         result.append(window)
         return False
     return True
Example #7
0
	def postPopup(self):
		"""Clean up after a popup dialog or menu.
		This should be called after a dialog or menu was popped up for the user.
		"""
		if not winUser.isWindowVisible(winUser.getForegroundWindow()):
			# The current foreground window is invisible, so we want to return to the previous foreground window.
			# Showing and hiding our main window seems to achieve this.
			self.Show()
			self.Hide()
Example #8
0
	def callback(window, data):
		if (
			(visible is None or winUser.isWindowVisible(window) == visible)
			and (not controlID or winUser.getControlID(window) == controlID)
			and (not className or winUser.getClassName(window) == className)
		):
			result.append(window)
			return False
		return True
Example #9
0
    def postPopup(self):
        """Clean up after a popup dialog or menu.
		This should be called after a dialog or menu was popped up for the user.
		"""
        if not winUser.isWindowVisible(winUser.getForegroundWindow()):
            # The current foreground window is invisible, so we want to return to the previous foreground window.
            # Showing and hiding our main window seems to achieve this.
            self.Show()
            self.Hide()
Example #10
0
	def _get_lastChild(self):
		childWindow=winUser.getTopWindow(self.windowHandle)
		nextWindow=winUser.getWindow(childWindow,winUser.GW_HWNDNEXT)
		while nextWindow:
			childWindow=nextWindow
			nextWindow=winUser.getWindow(childWindow,winUser.GW_HWNDNEXT)
		while childWindow and (not winUser.isWindowVisible(childWindow) or not winUser.isWindowEnabled(childWindow)):
			childWindow=winUser.getWindow(childWindow,winUser.GW_HWNDPREV)
		if childWindow:
			return Window(windowHandle=childWindow)
Example #11
0
 def checkStationsList(self):
     stationsListNVDAObject = findWindowNVDAObject("stationsList")
     if stationsListNVDAObject is None\
      or not winUser.isWindowVisible(stationsListNVDAObject.windowHandle):
         # try to  display stations list by pressing expand button
         clickButton("expandButton")
         time.sleep(1.0)
         stationsListNVDAObject = findWindowNVDAObject("stationsList")
         if stationsListNVDAObject is None\
          or not winUser.isWindowVisible(stationsListNVDAObject .windowHandle):
             # impossible to display list
             ui.message(_("Stations list not found"))
     if stationsListNVDAObject.childCount <= 2:
         # Translators: message to user
         # when there are none or one station in the list.
         ui.message(
             _("Not available because the station list is empty or has only one station"
               ))
         return False
     return True
Example #12
0
 def script_goToStationsList(self, gesture):
     if not self.inMainWindow():
         gesture.send()
         return
     obj = findWindowNVDAObject("stationsList")
     focus = api.getFocusObject()
     if obj == focus:
         ui.message(_("You are in stations list window"))
         return
     if obj is None or not winUser.isWindowVisible(obj.windowHandle):
         # try to  display stations list by pressing expand button
         clickButton("expandButton")
         time.sleep(1.0)
         obj = findWindowNVDAObject("stationsList")
         if obj is None or not winUser.isWindowVisible(obj.windowHandle):
             # impossible to display list
             ui.message(_("Stations list not found"))
             return
     # now set focus
     obj.setFocus()
     eventHandler.queueEvent("gainFocus", obj)
Example #13
0
	def __init__(self):
		style = wx.DEFAULT_FRAME_STYLE ^ wx.MAXIMIZE_BOX ^ wx.MINIMIZE_BOX | wx.FRAME_NO_TASKBAR
		super(MainFrame, self).__init__(None, wx.ID_ANY, versionInfo.name, size=(1,1), style=style)
		self.Bind(wx.EVT_CLOSE, self.onExitCommand)
		self.sysTrayIcon = SysTrayIcon(self)
		# This makes Windows return to the previous foreground window and also seems to allow NVDA to be brought to the foreground.
		self.Show()
		self.Hide()
		if winUser.isWindowVisible(self.Handle):
			# HACK: Work around a wx bug where Hide() doesn't actually hide the window,
			# but IsShown() returns False and Hide() again doesn't fix it.
			# This seems to happen if the call takes too long.
			self.Show()
			self.Hide()
Example #14
0
 def script_goToSearchEditBox(self, gesture):
     if not self.inMainWindow():
         gesture.send()
         return
     comboObj = findWindowNVDAObject("searchCombo")
     obj = api.getFocusObject()
     if comboObj == obj or comboObj.firstChild == obj:
         ui.message(_("You are in search edit field"))
         return
     if comboObj is None or not winUser.isWindowVisible(
             comboObj.windowHandle):
         # try to  display search edit box
         # and stations list by pressing expand button
         clickButton("expandButton")
         time.sleep(1.0)
         comboObj = findWindowNVDAObject("searchCombo")
         if comboObj is None or not winUser.isWindowVisible(
                 comboObj.windowHandle):
             # impossible to display search edit box
             ui.message(_("Search edit box not found"))
             return
     # now set focus
     comboObj.setFocus()
Example #15
0
def getPageTabActive (h):
	""" Get the handle of the active tab
	@param h the handle of the tab page """
	firstChild,next=5,2
	GetWindow=winUser.getWindow
	h=winUser.user32.GetParent(h)
	h=GetWindow(GetWindow(h,next),next)
	h=GetWindow(h,firstChild)
	i=1
	while winUser.isWindowVisible (h)==False:
		h=GetWindow(h,next)
		i+=1
		if not h :
			return
	return listPageTab[i-1]
Example #16
0
 def __init__(self):
     style = wx.DEFAULT_FRAME_STYLE ^ wx.MAXIMIZE_BOX ^ wx.MINIMIZE_BOX | wx.FRAME_NO_TASKBAR
     super(MainFrame, self).__init__(None,
                                     wx.ID_ANY,
                                     versionInfo.name,
                                     size=(1, 1),
                                     style=style)
     self.Bind(wx.EVT_CLOSE, self.onExitCommand)
     self.sysTrayIcon = SysTrayIcon(self)
     # This makes Windows return to the previous foreground window and also seems to allow NVDA to be brought to the foreground.
     self.Show()
     self.Hide()
     if winUser.isWindowVisible(self.Handle):
         # HACK: Work around a wx bug where Hide() doesn't actually hide the window,
         # but IsShown() returns False and Hide() again doesn't fix it.
         # This seems to happen if the call takes too long.
         self.Show()
         self.Hide()
	def __init__(self):
		style = wx.DEFAULT_FRAME_STYLE ^ wx.MAXIMIZE_BOX ^ wx.MINIMIZE_BOX | wx.FRAME_NO_TASKBAR
		super(MainFrame, self).__init__(None, wx.ID_ANY, versionInfo.name, size=(1,1), style=style)
		self.Bind(wx.EVT_CLOSE, self.onExitCommand)
		self.sysTrayIcon = SysTrayIcon(self)
		#: The focus before the last popup or C{None} if unknown.
		#: This is only valid before L{prePopup} is called,
		#: so it should be used as early as possible in any popup that needs it.
		#: @type: L{NVDAObject}
		self.prevFocus = None
		#: The focus ancestors before the last popup or C{None} if unknown.
		#: @type: list of L{NVDAObject}
		self.prevFocusAncestors = None
		# This makes Windows return to the previous foreground window and also seems to allow NVDA to be brought to the foreground.
		self.Show()
		self.Hide()
		if winUser.isWindowVisible(self.Handle):
			# HACK: Work around a wx bug where Hide() doesn't actually hide the window,
			# but IsShown() returns False and Hide() again doesn't fix it.
			# This seems to happen if the call takes too long.
			self.Show()
			self.Hide()
Example #18
0
	def onSelChanged(self, evt):
		self.selectedNode = evt.GetItem()
		if self.selectedNode:
			# retrieve the nvda object from the tree item data
			self.obj = self.tree.GetPyData(self.selectedNode)
			self.sb.SetStatusText("Children = " + str(len(self.obj.children)), 1)
			self.txtWindowControlID.ChangeValue(str(self.obj.windowControlID))
			if self.obj.name:
				self.txtName.ChangeValue(self.obj.name)
			else:
				self.txtName.ChangeValue("")
			if self.obj.value:
				self.txtValue.ChangeValue(self.obj.value)
			else:
				self.txtValue.ChangeValue("")
			self.txtRole.ChangeValue(controlTypes.roleLabels[self.obj.role])
			if winUser.isWindowVisible(self.obj.windowHandle):
				self.chkVisible.SetValue(True)
			else:
				self.chkVisible.SetValue(False)
			if controlTypes.STATE_FOCUSED in self.obj.states:
				self.chkFocused.SetValue(True)
			else:
				self.chkFocused.SetValue(False)
			self.txtAbsLocLeft.ChangeValue(str(self.obj.location[LOC_LEFT]))
			self.txtAbsLocTop.ChangeValue(str(self.obj.location[LOC_TOP]))
			self.txtAbsLocWidth.ChangeValue(str(self.obj.location[LOC_WIDTH]))
			self.txtAbsLocHeight.ChangeValue(str(self.obj.location[LOC_HEIGHT]))
			self.txtRelLocLeft.ChangeValue(str(self.obj.location[0]-self.fg.location[LOC_LEFT]))
			self.txtRelLocTop.ChangeValue(str(self.obj.location[1]-self.fg.location[LOC_TOP]))
			self.txtRelLocWidth.ChangeValue(str(self.obj.location[LOC_WIDTH]))
			self.txtRelLocHeight.ChangeValue(str(self.obj.location[LOC_HEIGHT]))
			self.lstStates.Clear()
			for state in self.obj.states:
				self.lstStates.Append(controlTypes.stateLabels[state], None)
				self.lstStates.SetSelection(0)
Example #19
0
	def _get_next(self):
		nextWindow=winUser.getWindow(self.windowHandle,winUser.GW_HWNDNEXT)
		while nextWindow and (not winUser.isWindowVisible(nextWindow) or not winUser.isWindowEnabled(nextWindow)):
			nextWindow=winUser.getWindow(nextWindow,winUser.GW_HWNDNEXT)
		if nextWindow:
			return Window(windowHandle=nextWindow)
Example #20
0
    def script_startStationRandomly(self, gesture):
        from . import rs_translations
        rs_translations.initialize()
        foreground = api.getForegroundObject()
        if foreground.name != "Radio? Sure!":
            clickButtonWithoutMoving("playButton")
        h = findWindow("stationsList")
        if not h or not winUser.isWindowVisible(h):
            # try to  display stations list by pressing expand button
            clickButton("expandButton")
            time.sleep(1.0)
            h = findWindow("stationsList")
            if not h or not winUser.isWindowVisible(h):
                # impossible to display list
                ui.message(_("Stations list not found"))
                return

        def callback(stationsListNVDAObject):
            from .rs_translations import getPlayingTranslation
            maxStationsToCheck = _addonConfigManager.getMaxStationsToCheck()
            stationCount = maxStationsToCheck
            while stationCount:
                stationCount -= 1
                station = self.startStation(stationsListNVDAObject)
                maxDelayForConnexion = _addonConfigManager.getMaxDelayForConnexion(
                )
                while maxDelayForConnexion:
                    maxDelayForConnexion -= 1
                    time.sleep(1.0)
                    infos = getPlayInfos()
                    if getPlayingTranslation() in infos:
                        # station is playing
                        log.warning("playing: %s" % station.name)
                        eventHandler.queueEvent("gainFocus", station)
                        return
                # it's a bad station
                log.warning("no connexion: %s" % station.name)
                _addonConfigManager.recordBadStation(station.name)
                self.badStations.append(station.name)
                if stationCount == 0:
                    # Translators: message to user there is none station with connexion.
                    queueHandler.queueFunction(
                        queueHandler.eventQueue,
                        ui.message,
                        # Translators: message to user
                        _("None of the %s stations selected randomly could be connected"
                          ) % maxStationsToCheck)
                    eventHandler.queueEvent("gainFocus", station)
                else:
                    if maxStationsToCheck - stationCount:
                        tones.beep(500, 50)

        stationsListNVDAObject = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
            h, -4, 0)
        if stationsListNVDAObject.childCount == 1:
            # no station in list
            # Translators: message to user there is no station in list.
            queueHandler.queueFunction(
                queueHandler.eventQueue,
                ui.message,
                # Translators: message to user there is no stations in list.
                _("No station in list"))
            return
        # Translators: message to user when station search is starting.
        queueHandler.queueFunction(
            queueHandler.eventQueue,
            ui.message,
            # Translators: message to user  to report station search running
            _("Station search running"))
        queueHandler.queueFunction(queueHandler.eventQueue, callback,
                                   stationsListNVDAObject)
Example #21
0
	def event_stateChange(self, obj, nextHandler):
		if obj.role == controlTypes.ROLE_DOCUMENT and controlTypes.STATE_BUSY in obj.states and winUser.isWindowVisible(obj.windowHandle) and obj.isInForeground:
			statusBar = api.getStatusBar()
			if statusBar:
				statusText = api.getStatusBarText(statusBar)
				speech.cancelSpeech()
				speech.speakMessage(controlTypes.speechStateLabels[controlTypes.STATE_BUSY])
				speech.speakMessage(statusText)
				return
		nextHandler()
Example #22
0
	def event_gainFocus(self, obj, nextHandler):
		if obj.role == controlTypes.Role.DOCUMENT and controlTypes.State.BUSY in obj.states and winUser.isWindowVisible(obj.windowHandle):
			statusBar = api.getStatusBar()
			if statusBar:
				try:
					# The document loading status is contained in the second field of the status bar.
					statusText = statusBar.firstChild.next.name
				except:
					# Fall back to reading the entire status bar.
					statusText = api.getStatusBarText(statusBar)
				speech.speakMessage(controlTypes.stateLabels[controlTypes.State.BUSY])
				speech.speakMessage(statusText)
				return
		nextHandler()
Example #23
0
def findGroupboxObject(obj):
	prevWindow=winUser.getPreviousWindow(obj.windowHandle)
	while prevWindow:
		if winUser.getClassName(prevWindow)=="Button" and winUser.getWindowStyle(prevWindow)&winUser.BS_GROUPBOX and winUser.isWindowVisible(prevWindow):
			groupObj=NVDAObjects.IAccessible.getNVDAObjectFromEvent(prevWindow,winUser.OBJID_CLIENT,0)
			try:
				(left,top,width,height)=obj.location
				(groupLeft,groupTop,groupWidth,groupHeight)=groupObj.location
			except:
				return
			if groupObj.IAccessibleRole==oleacc.ROLE_SYSTEM_GROUPING and left>=groupLeft and (left+width)<=(groupLeft+groupWidth) and top>=groupTop and (top+height)<=(groupTop+groupHeight):
				return groupObj
		prevWindow=winUser.getPreviousWindow(prevWindow)
Example #24
0
 def event_stateChange(self, obj, nextHandler):
     if obj.role == controlTypes.ROLE_DOCUMENT and controlTypes.STATE_BUSY in obj.states and winUser.isWindowVisible(
             obj.windowHandle) and obj.isInForeground:
         statusBar = api.getStatusBar()
         if statusBar:
             statusText = api.getStatusBarText(statusBar)
             speech.cancelSpeech()
             speech.speakMessage(
                 controlTypes.stateLabels[controlTypes.STATE_BUSY])
             speech.speakMessage(statusText)
             return
     nextHandler()
def findGroupboxObject(obj):
	prevWindow=winUser.getPreviousWindow(obj.windowHandle)
	while prevWindow:
		if winUser.getClassName(prevWindow)=="Button" and winUser.getWindowStyle(prevWindow)&winUser.BS_GROUPBOX and winUser.isWindowVisible(prevWindow):
			groupObj=NVDAObjects.IAccessible.getNVDAObjectFromEvent(prevWindow,winUser.OBJID_CLIENT,0)
			try:
				(left,top,width,height)=obj.location
				(groupLeft,groupTop,groupWidth,groupHeight)=groupObj.location
			except:
				return
			if groupObj.IAccessibleRole==oleacc.ROLE_SYSTEM_GROUPING and left>=groupLeft and (left+width)<=(groupLeft+groupWidth) and top>=groupTop and (top+height)<=(groupTop+groupHeight):
				return groupObj
		prevWindow=winUser.getPreviousWindow(prevWindow)
Example #26
0
	def event_gainFocus(self, obj, nextHandler):
		if obj.role == controlTypes.ROLE_DOCUMENT and controlTypes.STATE_BUSY in obj.states and winUser.isWindowVisible(obj.windowHandle):
			statusBar = api.getStatusBar()
			if statusBar:
				try:
					# The document loading status is contained in the second field of the status bar.
					statusText = statusBar.firstChild.next.name
				except:
					# Fall back to reading the entire status bar.
					statusText = api.getStatusBarText(statusBar)
				speech.speakMessage(controlTypes.stateLabels[controlTypes.STATE_BUSY])
				speech.speakMessage(statusText)
				return
		nextHandler()
Example #27
0
	def _get_previous(self):
		prevWindow=winUser.getWindow(self.windowHandle,winUser.GW_HWNDPREV)
		while prevWindow and (not winUser.isWindowVisible(prevWindow) or not winUser.isWindowEnabled(prevWindow)):
			prevWindow=winUser.getWindow(prevWindow,winUser.GW_HWNDPREV)
		if prevWindow:
			return Window(windowHandle=prevWindow)