Exemple #1
0
	def _gainedFocus(self):
		# The user has entered this Skype conversation.
		if self.appModule.conversation:
			# Another conversation was previously focused. Clean it up.
			self.appModule.conversation.lostFocus()

		self.appModule.conversation = self
		try:
			self.outputList = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(self.windowHandle, className="TChatContentControl"),
				winUser.OBJID_CLIENT, 0).lastChild
		except LookupError:
			log.debugWarning("Couldn't find output list")
			self.outputList = None
		else:
			self.outputList.startMonitoring()
		for wClass, role in TYPING_INDICATOR_MATCH:
			try:
				self.typingIndicator = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
					windowUtils.findDescendantWindow(self.windowHandle, className=wClass),
					winUser.OBJID_CLIENT, 1)
			except LookupError:
				continue
			self.typingIndicator.startMonitoring()
			break
		else:
			log.debugWarning("Couldn't find typing indicator")
			self.typingIndicator = None
Exemple #2
0
 def script_sent(self, gesture):
     global orig
     fg = api.getForegroundObject()
     try:
         handle = windowUtils.findDescendantWindow(
             fg.windowHandle, className="RichEdit20WPT", controlID=4098)
         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:
         # for RSS mails
         try:
             handle = windowUtils.findDescendantWindow(
                 fg.windowHandle, className="RichEdit20WPT", controlID=4105)
             if handle:
                 # found handle
                 w = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
                     handle, winUser.OBJID_CLIENT, 0)
                 ui.message(" %s %s" % (w.name, w.value))
         except LookupError:
             tones.beep(440, 20)
    def getAttachmentInfos2013(self):
        fg = api.getForegroundObject()
        cidAttachments = 4623
        bFoundWindow = False
        bResult = False
        try:
            handle = findDescendantWindow(fg.windowHandle,
                                          className=None,
                                          controlID=cidAttachments)
            bFoundWindow = True
            obj = getNVDAObjectFromEvent(handle, winUser.OBJID_CLIENT, 0)
            if not (obj.location.width == 0 and obj.location.height == 0):
                attachmentsList = [
                    c for c in obj.children[1:]
                    if c.role == controlTypes.Role.LISTITEM
                ]
                namesGen = (a.name for a in attachmentsList)
                bResult = True
        except LookupError:
            pass
        if not bResult:
            cidAttachments = 4104
            try:
                handle = findDescendantWindow(fg.windowHandle,
                                              className=None,
                                              controlID=cidAttachments)
                obj = getNVDAObjectFromEvent(handle, winUser.OBJID_CLIENT, 0)
                if obj.firstChild is None:
                    raise LookupError
                bFoundWindow = True

                def makeGenChildren(
                    o
                ):  #Define a generator to get children since the .children roperty does not work
                    o = o.firstChild
                    while o is not None:
                        if o.role == controlTypes.Role.BUTTON:
                            yield o
                        o = o.next

                attachmentsList = [o for o in makeGenChildren(obj)]
                namesGen = (a.name for a in attachmentsList)
                bResult = True
            except LookupError:
                pass
        if not bFoundWindow:
            raise LookupError
        if bResult:
            return attachmentsList, handle, namesGen, obj.name
        else:
            return [], handle, [], obj.name
Exemple #4
0
 def getHeaderFieldObject(self, nField):
     try:
         cid, name = self.getHeaderFieldsFun()[nField]
     except KeyError:
         raise HeaderFieldNotFoundeError()
     try:
         handle = findDescendantWindow(self.rootDialog.windowHandle,
                                       controlID=cid)
         if handle:
             obj = getNVDAObjectFromEvent(handle, winUser.OBJID_CLIENT, 0)
     except LookupError:
         raise HeaderFieldNotFoundeError()
     except AttributeError:  # Exception raised when performing tests calling self.rootDialog.windowHandle on FakeRootDialog
         obj = [
             o for o in self.rootDialog.children if o.windowControlID == cid
         ]
         if len(obj) != 1:
             infos = {
                 'obj': obj,
                 'cid': cid,
                 'name': name,
             }
             log.debug(f'Header field not found. Infos: {infos}')
             raise HeaderFieldNotFoundeError()
         obj = obj[0]
     if controlTypes.STATE_INVISIBLE in obj.states:
         raise HeaderFieldNotFoundeError()
     return obj, name
 def getHeaderFieldObject(self, nField):
     dicHeaderFields = self.getHeaderFieldsFun()
     try:
         cid, name = dicHeaderFields[nField]
     except KeyError:
         msg = f'The key {nField} is not present in the dictionary {dicHeaderFields}'
         raise HeaderFieldNotFoundeError(msg)
     if isinstance(cid, tuple):
         cids = cid
     else:
         cids = (cid, )
     if self.rootDialog.name != 'Fake root':
         msgList = []
         for cid in cids:
             try:
                 handle = findDescendantWindow(self.rootDialog.windowHandle,
                                               controlID=cid)
                 if handle:
                     obj = getNVDAObjectFromEvent(handle,
                                                  winUser.OBJID_CLIENT, 0)
                     if controlTypes.State.INVISIBLE in obj.states:
                         msgList.append(
                             f'Object (cid={obj.windowControlID}) is invisible'
                         )
                     else:
                         break
                 else:
                     msgList.append(f'Handle={handle} found for cid={cid}')
             except LookupError:
                 msgList.append(f'LookupError for cid={cid}')
         else:
             msg = f'No window found for cids={cids}. Details below:\n' + '\n'.join(
                 msgList)
             raise HeaderFieldNotFoundeError(msg)
     else:
         log.debug('FakeRootDialog')
         obj = [
             o for o in self.rootDialog.children
             if o.windowControlID in cids
         ]
         nObj = len(obj)
         if nObj != 1:
             infoDic = {
                 'obj':
                 obj,
                 'children':
                 str([o.windowControlID for o in self.rootDialog.children]),
                 'cids':
                 cids,
                 'name':
                 name,
             }
             info = '\n'.join(f'{k}: {v}' for (k, v) in infoDic.items())
             msg = f'Fake root window: {nObj} objects found, 1 expected. Info =\n{info}'
             raise HeaderFieldNotFoundeError(msg)
         obj = obj[0]
         if controlTypes.State.INVISIBLE in obj.states:
             msg = f'Object (cid={obj.windowControlID}) is invisible'
             raise HeaderFieldNotFoundeError(msg)
     return obj, name
Exemple #6
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)
def getDocument():
	try:
		document = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
			windowUtils.findDescendantWindow(api.getForegroundObject().windowHandle, className="Internet Explorer_Server"),
			winUser.OBJID_CLIENT, 0)
		return document
	except LookupError:
		return None
Exemple #8
0
 def getChatHistoryWindow(self):
     fg = api.getForegroundObject()
     lastChild = fg.lastChild
     if controlTypes.STATE_INVISIBLE not in lastChild.states:
         handle = windowUtils.findDescendantWindow(lastChild.windowHandle, className="TChatContentControl")
         return handle
     else:
         raise LookupError("Chat history list not visible.")
Exemple #9
0
def findDetails():
    try:
        obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
            windowUtils.findDescendantWindow(
                api.getForegroundObject().windowHandle, controlID=1),
            winUser.OBJID_CLIENT, 0)
    except LookupError:
        ui.message("no")
        return None
Exemple #10
0
	def getHeader(self):
		try:
			return self.header
		except AttributeError:
			#handle = findDescendantWindow(api.getForegroundObject().windowHandle, controlID=138, className='SysHeader32')
			handle = findDescendantWindow(self.parent.windowHandle, controlID=138, className='SysHeader32')
			self.header = getNVDAObjectFromEvent(handle, winUser.OBJID_CLIENT, 0)
			self.allowIAccessibleChildIDAndChildCountForPositionInfo = True
			return self.header
Exemple #11
0
def isRecordingReady():
    fg = api.getForegroundObject()
    hTime = readOrRecord()
    hRecord = windowUtils.findDescendantWindow(fg.windowHandle, controlID=160)
    text = getNVDAObjectFromEvent(hTime, OBJID_CLIENT, CHILDID_SELF).value
    text1 = getNVDAObjectFromEvent(hRecord, OBJID_CLIENT, CHILDID_SELF).value
    if not text1 and (text and not text.isspace()):
        return True
    return False
Exemple #12
0
def getPoeditWindow(index, visible=True):
	try:
		obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
			windowUtils.findDescendantWindow(api.getForegroundObject().windowHandle, visible,
			controlID=index), winUser.OBJID_CLIENT, 0)
	except LookupError:
		return None
	objText = obj.value
	return objText if objText else False
Exemple #13
0
	def getInfoBarObj(self):
		try:
			cid = self.getInfoBarControlId()
			obj = getNVDAObjectFromEvent(
			findDescendantWindow(api.getForegroundObject().windowHandle, visible=True, className=None, controlID=cid),
			winUser.OBJID_CLIENT, 0)
		except LookupError:
			obj = None
		return obj
Exemple #14
0
	def getToolBar(self):
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, visible=True, controlID=16127
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return None
		return obj
Exemple #15
0
def selectionDuration():
    if checkSelection():
        fg = api.getForegroundObject()
        hwnd = windowUtils.findDescendantWindow(fg.windowHandle, controlID=160)
        o = getNVDAObjectFromEvent(hwnd, OBJID_CLIENT, CHILDID_SELF)
        text = o.value
        selectionDuration = text.split('(')
        selectionDuration = selectionDuration[1]
        selectionDuration = selectionDuration[:-1]
        return timeSplitter(selectionDuration)
Exemple #16
0
def beginSelection():
    if checkSelection():
        fg = api.getForegroundObject()
        hwnd = windowUtils.findDescendantWindow(fg.windowHandle, controlID=160)
        o = getNVDAObjectFromEvent(hwnd, OBJID_CLIENT, CHILDID_SELF)
        text = o.value
        beginSelection = text.split(' - ')
        beginSelection = beginSelection[0]
        beginSelection = beginSelection.split()[1]
        return timeSplitter(beginSelection)
Exemple #17
0
	def script_focusToMessageBody(self, gesture):
		try:
			obj = getNVDAObjectFromEvent(
			findDescendantWindow(api.getForegroundObject().windowHandle, visible=True, className=None, controlID=4159),
			winUser.OBJID_CLIENT, 0)
		except LookupError:
			# Translators: Error when trying to move focus in message body
			ui.message(_("Not in a message window"))
			return
		obj.setFocus()
Exemple #18
0
def checkSelection():
    fg = api.getForegroundObject()
    hwnd = windowUtils.findDescendantWindow(fg.windowHandle, controlID=160)
    o = getNVDAObjectFromEvent(hwnd, OBJID_CLIENT, CHILDID_SELF)
    text = o.value
    if text and not text.isspace():
        text = text.split()
        if text[0].endswith(':'):
            return True
    return False
Exemple #19
0
def isRecording():
    fg = api.getForegroundObject()
    hwnd = windowUtils.findDescendantWindow(fg.windowHandle, controlID=160)
    o = getNVDAObjectFromEvent(hwnd, OBJID_CLIENT, CHILDID_SELF)
    text = o.value
    if text and not text.isspace():
        text = text.split()
        if text[1].startswith("'"):
            return True
    return False
Exemple #20
0
 def script_message(self, gesture):
     fg = api.getForegroundObject()
     try:
         handle = windowUtils.findDescendantWindow(fg.windowHandle,
                                                   className="AfxWndA",
                                                   controlID=4159)
         if handle:
             # found handle
             winUser.setForegroundWindow(handle)
     except LookupError:
         tones.beep(440, 20)
 def script_touchKeyboardEnable(self, gesture):
     # Locate the touch keyboard button and activate it, simulating JAWS 17 gesture.
     keyboardButtonHwnd = windowUtils.findDescendantWindow(
         api.getDesktopObject().windowHandle, className="TIPBand")
     touchKeyboardButton = getNVDAObjectFromEvent(keyboardButtonHwnd,
                                                  winUser.OBJID_CLIENT, 0)
     try:
         touchKeyboardButton.doAction()
         tones.beep(1000, 150)
     except NotImplementedError:
         # Translators: message shown when touch keyboard button is not found.
         ui.message(_("Cannot activate touch keyboard"))
Exemple #22
0
	def script_list(self, gesture):
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, visible=True, className="SysListView32"
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			mouseHandler.doPrimaryClick()
Exemple #23
0
 def script_moveToChatEntryEdit(self, gesture):
     fg = api.getForegroundObject()
     lastChild = fg.lastChild
     # If there is an active conversation being shown, then it is the last child of fg (which should be visible), and has the class u'TConversationForm'
     if controlTypes.STATE_INVISIBLE not in lastChild.states and lastChild.windowClassName == "TConversationForm":
         try:
             handle = windowUtils.findDescendantWindow(lastChild.windowHandle, None, None, className="TChatRichEdit")
             self.moveFocusTo(handle)
         except LookupError:
             log.debugWarning("Couldn't find chat entry edit.")
             ui.message(MSG_NO_ACTIVE_CONVERSATION)
     else:
         ui.message(MSG_NO_ACTIVE_CONVERSATION)
Exemple #24
0
	def getHeaderFieldObject(self, nField):
		try:
			cid,name = self.getHeaderFieldsFun()[nField]
		except KeyError:
			raise HeaderFieldNotFoundeError()
		try:
			handle = findDescendantWindow(self.rootDialog.windowHandle, controlID=cid)
			if handle:
				obj = getNVDAObjectFromEvent(handle, winUser.OBJID_CLIENT, 0)
		except:
			raise HeaderFieldNotFoundeError()
		if controlTypes.STATE_INVISIBLE in obj.states:
			raise HeaderFieldNotFoundeError()
		return obj,name
Exemple #25
0
	def getAttachmentInfos2016(self):
		fg = api.getForegroundObject()
		cidAttachments=4306
		handle = findDescendantWindow(fg.windowHandle, className=None, controlID=cidAttachments)
		obj = getNVDAObjectFromEvent(handle, winUser.OBJID_CLIENT, 0)
		try:
			o = obj
			while o.role != controlTypes.ROLE_BUTTON:
				o = o.firstChild
			attachmentsList = [a for a in o.parent.children if a.role == controlTypes.ROLE_BUTTON]
		except AttributeError:
			attachmentsList = []
		namesGen = (child.firstChild.getChild(1).name for child in attachmentsList)
		return attachmentsList,handle,namesGen,obj.name
Exemple #26
0
	def script_name(self, gesture):
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, visible=True, controlID=2183
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Exemple #27
0
def part(flag=None):
    if checkPart():
        fg = api.getForegroundObject()
        hwnd = windowUtils.findDescendantWindow(fg.windowHandle, controlID=160)
        o = getNVDAObjectFromEvent(hwnd, OBJID_CLIENT, CHILDID_SELF)
        text = o.value
        text = text.split('(')
        text = text[1]
        text = text.split(')')
        text = text[0]
        text = text.replace(u'/', ' {0} '.format(_('of')))
        return u'{0} {1}'.format(announce[10],
                                 text) if not flag else '{0} {1}'.format(
                                     _('Part'), text)
Exemple #28
0
	def script_searchList(self, gesture):
		where = self.getWhere()
		if not hasattr(where, "IAccessibleChildID") or where.IAccessibleChildID != 6:
			return
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, controlID=2833
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			mouseHandler.doPrimaryClick()
Exemple #29
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."))
	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."))
Exemple #31
0
	def script_readOnlyEdit(self, gesture):
		where = self.getWhere()
		if hasattr(where, "IAccessibleChildID") and where.IAccessibleChildID == 9:
			cID = -1
		else:
			cID = None
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, visible=True, className="RichEdit20W", controlID=cID
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			mouseHandler.doPrimaryClick()
Exemple #32
0
	def conversationMaybeFocused(self, obj):
		if not isinstance(obj, NVDAObjects.IAccessible.IAccessible) or obj.windowClassName != "TConversationForm" or obj.IAccessibleRole != oleacc.ROLE_SYSTEM_CLIENT:
			# This isn't a Skype conversation.
			return
		# The user has entered a Skype conversation.

		if self.chatWindow:
			# Another conversation was already focused and hasn't been cleaned up yet.
			self.conversationLostFocus()

		window = obj.windowHandle
		self.chatWindow = window
		try:
			self.chatOutputList = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(window, className="TChatContentControl"),
				winUser.OBJID_CLIENT, 1)
		except LookupError:
			pass
		else:
			self.chatOutputList.startMonitoring()
	def script_touchKeyboardEnable(self, gesture):
		# Locate the touch keyboard button and activate it, simulating JAWS 17 gesture.
		keyboardButtonHwnd = windowUtils.findDescendantWindow(api.getDesktopObject().windowHandle, className="TIPBand")
		touchKeyboardButton = getNVDAObjectFromEvent(keyboardButtonHwnd, winUser.OBJID_CLIENT, 0)
		touchKeyboardButton.doAction()
		tones.beep(1000, 150)