Exemplo n.º 1
0
	def _get_displayText(self):
		"""The text at this object's location according to the display model for this object's window."""
		try:
			left,top,width,height=self.location
		except TypeError:
			log.debugWarning("No location, returning no text")
			return ""
		import displayModel
		text,rects=displayModel.getWindowTextInRect(self.appModule.helperLocalBindingHandle,self.windowHandle,left,top,left+width,top+height,8,32)
		return text or ""
Exemplo n.º 2
0
	def _getColumnContent(self, column):
		superContent = super(TorrentContentsListItem, self)._getColumnContent(column)
		if superContent or column != 1:
			return superContent
		# We need to use the display model to retrieve the Name column.
		try:
			left, top, width, height = self._getColumnLocation(column)
			return displayModel.getWindowTextInRect(self.appModule.helperLocalBindingHandle, self.windowHandle,
				left, top, left + width, top + height,
				displayModel.DisplayModelTextInfo.minHorizontalWhitespace, displayModel.DisplayModelTextInfo.minVerticalWhitespace)[0]
		except:
			log.debugWarning("Error retrieving name using display model", exc_info=True)
			return superContent
Exemplo n.º 3
0
	def _get_displayText(self):
		"""The text at this object's location according to the display model for this object's window."""
		try:
			left,top,width,height=self.location
		except TypeError:
			log.debugWarning("No location, returning no text")
			return ""
		import displayModel
		bindingHandle=self.appModule.helperLocalBindingHandle
		if not bindingHandle:
			log.debugWarning("appModule has no binding handle")
			return ""
		text,rects=displayModel.getWindowTextInRect(bindingHandle,self.windowHandle,left,top,left+width,top+height,8,32)
		return text or ""
Exemplo n.º 4
0
 def _getEmbeddedObjectLabel(self, embedRangeObj):
     label = None
     try:
         o = embedRangeObj.GetEmbeddedObject()
     except comtypes.COMError:
         o = None
     if not o:
         return None
     import oleacc
     try:
         label = o.QueryInterface(oleacc.IAccessible).accName(0)
     except comtypes.COMError:
         pass
     if label:
         return label
     left, top = embedRangeObj.GetPoint(comInterfaces.tom.tomStart)
     right, bottom = embedRangeObj.GetPoint(comInterfaces.tom.tomEnd)
     import displayModel
     label = displayModel.getWindowTextInRect(
         self.obj.appModule.helperLocalBindingHandle, self.obj.windowHandle,
         left, top, right, bottom + 10, 1, 1)[0]
     if label and not label.isspace():
         return label
     try:
         dataObj = o.QueryInterface(oleTypes.IDataObject)
     except comtypes.COMError:
         dataObj = None
     if dataObj:
         try:
             dataObj = pythoncom._univgw.interface(
                 hash(dataObj), pythoncom.IID_IDataObject)
             format = (win32clipboard.CF_UNICODETEXT, None,
                       pythoncom.DVASPECT_CONTENT, -1,
                       pythoncom.TYMED_HGLOBAL)
             medium = dataObj.GetData(format)
             buf = ctypes.create_string_buffer(medium.data)
             buf = ctypes.cast(buf, ctypes.c_wchar_p)
             label = buf.value
         except:
             pass
     if label:
         return label
     try:
         oleObj = o.QueryInterface(oleTypes.IOleObject)
         label = oleObj.GetUserType(1)
     except comtypes.COMError:
         pass
     return label
Exemplo n.º 5
0
	def _getEmbeddedObjectLabel(self,embedRangeObj):
		label=None
		try:
			o=embedRangeObj.GetEmbeddedObject()
		except comtypes.COMError:
			o=None
		if not o:
			return None
		import oleacc
		try:
			label=o.QueryInterface(oleacc.IAccessible).accName(0);
		except comtypes.COMError:
			pass
		if label:
			return label
		left,top=embedRangeObj.GetPoint(comInterfaces.tom.tomStart)
		right,bottom=embedRangeObj.GetPoint(comInterfaces.tom.tomEnd)
		import displayModel
		label=displayModel.getWindowTextInRect(self.obj.appModule.helperLocalBindingHandle, self.obj.windowHandle, left, top, right, bottom+10,1,1)[0]
		if label and not label.isspace():
			return label
		try:
			dataObj=o.QueryInterface(oleTypes.IDataObject)
		except comtypes.COMError:
			dataObj=None
		if dataObj:
			try:
				dataObj=pythoncom._univgw.interface(hash(dataObj),pythoncom.IID_IDataObject)
				format=(win32clipboard.CF_UNICODETEXT, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL)
				medium=dataObj.GetData(format)
				buf=ctypes.create_string_buffer(medium.data)
				buf=ctypes.cast(buf,ctypes.c_wchar_p)
				label=buf.value
			except:
				pass
		if label:
			return label
		try:
			oleObj=o.QueryInterface(oleTypes.IOleObject)
			label=oleObj.GetUserType(1)
		except comtypes.COMError:
			pass
		return label
Exemplo n.º 6
0
	def _get_name(self):
		superName = super(TorrentContentsListItem, self).name
		if superName:
			return superName

		# We need to use the display model to retrieve the Name column.
		try:
			# We don't want to just use displayText because it also contains the size, which is exposed correctly in the value property.
			# Therefore, use the left and right of the Name column as obtained from the column header.
			nameHdrLoc = Window._get_firstChild(self).firstChild.firstChild.location
			left = nameHdrLoc[0]
			right = left + nameHdrLoc[2]
			# Use the top and bottom of the list item.
			selfLoc = self.location
			top = selfLoc[1]
			bottom = top + selfLoc[3]
			return displayModel.getWindowTextInRect(self.appModule.helperLocalBindingHandle, self.windowHandle,
				left, top, right, bottom,
				displayModel.DisplayModelTextInfo.minHorizontalWhitespace, displayModel.DisplayModelTextInfo.minVerticalWhitespace)[0]
		except:
			log.debugWarning("Error retrieving name using display model", exc_info=True)
			return superName