Exemple #1
0
	def unloadBuffer(self):
		if self.VBufHandle is not None:
			try:
				watchdog.cancellableExecute(NVDAHelper.localLib.VBuf_destroyBuffer, ctypes.byref(ctypes.c_int(self.VBufHandle)))
			except WindowsError:
				pass
			self.VBufHandle=None
Exemple #2
0
	def unloadBuffer(self):
		if self.VBufHandle is not None:
			try:
				watchdog.cancellableExecute(NVDAHelper.localLib.VBuf_destroyBuffer, ctypes.byref(ctypes.c_int(self.VBufHandle)))
			except WindowsError:
				pass
			self.VBufHandle=None
Exemple #3
0
def getWindowTextInRect(
    bindingHandle, windowHandle, left, top, right, bottom, minHorizontalWhitespace, minVerticalWhitespace, useXML=False
):
    text, cpBuf = watchdog.cancellableExecute(
        _getWindowTextInRect,
        bindingHandle,
        windowHandle,
        left,
        top,
        right,
        bottom,
        minHorizontalWhitespace,
        minVerticalWhitespace,
        useXML,
    )
    if not text or not cpBuf:
        return u"", []

    characterLocations = []
    cpBufIt = iter(cpBuf)
    for cp in cpBufIt:
        characterLocations.append(
            (ord(cp), ord(next(cpBufIt)), ord(next(cpBufIt)), ord(next(cpBufIt)), c_short(ord(next(cpBufIt))).value)
        )
    return text, characterLocations
Exemple #4
0
    def deactivate(self, evt):
        progressDialog = gui.IndeterminateProgressDialog(
            self, _("Performing request"),
            _("Please wait while your license is being deactivated..."))

        try:
            success, message = watchdog.cancellableExecute(
                self.lib.DeactivateLicense)
        except:
            success = False
            message = _("There was a timeout while performing your request.")
            log.ERROR("Activation error", exc_info=True)

        if not success:
            wx.CallAfter(
                gui.messageBox,
                _("An error has occured:\n{error}").format(error=message),
                _("Error"), wx.OK | wx.ICON_ERROR)
        else:
            evt.Skip()
            wx.CallAfter(
                gui.messageBox,
                _("UnicornDVC has been deactivated!\nAdditional info: {message}"
                  ).format(message=message), _("Congratulations!"),
                wx.OK | wx.ICON_EXCLAMATION)
        progressDialog.done()
Exemple #5
0
    def activate(self, evt):
        if not self.key.Value:
            gui.messageBox(_("You must enter a valid license key."),
                           _("Error"), wx.OK | wx.ICON_ERROR)
            self.key.SetFocus()
            return
        progressDialog = gui.IndeterminateProgressDialog(
            self, _("Performing request"),
            _("Please wait while your license is being activated..."))

        try:
            success, message = watchdog.cancellableExecute(
                self.lib.ActivateLicense, self.key.Value)
        except Exception:
            success = False
            message = _("There was an error while performing your request.")
            log.error("Activation error", exc_info=True)

        if not success:
            wx.CallAfter(
                gui.messageBox,
                _("An error has occured:\n{error}").format(error=message),
                _("Error"), wx.OK | wx.ICON_ERROR)
        else:
            evt.Skip()
            wx.CallAfter(
                gui.messageBox,
                _("UnicornDVC has been activated!\nAdditional info: {message}"
                  ).format(message=message), _("Congratulations!"),
                wx.OK | wx.ICON_EXCLAMATION)
        progressDialog.done()
def getWindowTextInRect(bindingHandle,
                        windowHandle,
                        left,
                        top,
                        right,
                        bottom,
                        minHorizontalWhitespace,
                        minVerticalWhitespace,
                        stripOuterWhitespace=True,
                        includeDescendantWindows=True):
    text, cpBuf = watchdog.cancellableExecute(
        _getWindowTextInRect, bindingHandle, windowHandle,
        includeDescendantWindows, left, top, right, bottom,
        minHorizontalWhitespace, minVerticalWhitespace, stripOuterWhitespace)
    if not text or not cpBuf:
        return u"", []

    characterLocations = []
    cpBufIt = iter(cpBuf)
    for cp in cpBufIt:
        left, top, right, bottom = (wcharToInt(cp), wcharToInt(next(cpBufIt)),
                                    wcharToInt(next(cpBufIt)),
                                    wcharToInt(next(cpBufIt)))
        if right < left:
            left, right = right, left
        characterLocations.append(RectLTRB(left, top, right, bottom))
    return text, characterLocations
Exemple #7
0
def requestTextChangeNotifications(obj, enable):
	"""Request or cancel notifications for when the display text changes in an NVDAObject.
	A textChange event (event_textChange) will be fired on the object when its text changes.
	Note that this event does not provide any information about the changed text itself.
	It is important to request that notifications be cancelled when you no longer require them or when the object is no longer in use,
	as otherwise, resources will not be released.
	@param obj: The NVDAObject for which text change notifications are desired.
	@type obj: NVDAObject
	@param enable: C{True} to enable notifications, C{False} to disable them.
	@type enable: bool
	"""
	if not enable:
		_textChangeNotificationObjs.remove(obj)
	watchdog.cancellableExecute(_requestTextChangeNotificationsForWindow, obj.appModule.helperLocalBindingHandle, obj.windowHandle, enable)
	if enable:
		_textChangeNotificationObjs.append(obj)
	def getListGroupInfo(self,groupIndex):
		header=AutoFreeBSTR()
		footer=AutoFreeBSTR()
		state=c_int()
		if watchdog.cancellableExecute(NVDAHelper.localLib.nvdaInProcUtils_sysListView32_getGroupInfo,self.appModule.helperLocalBindingHandle,self.windowHandle,groupIndex,byref(header),byref(footer),byref(state))!=0:
			return None
		return dict(header=header.value,footer=footer.value,state=state.value,groupIndex=groupIndex)
Exemple #9
0
def requestTextChangeNotifications(obj, enable):
	"""Request or cancel notifications for when the display text changes in an NVDAObject.
	A textChange event (event_textChange) will be fired on the object when its text changes.
	Note that this event does not provide any information about the changed text itself.
	It is important to request that notifications be cancelled when you no longer require them or when the object is no longer in use,
	as otherwise, resources will not be released.
	@param obj: The NVDAObject for which text change notifications are desired.
	@type obj: NVDAObject
	@param enable: C{True} to enable notifications, C{False} to disable them.
	@type enable: bool
	"""
	if not enable:
		_textChangeNotificationObjs.remove(obj)
	watchdog.cancellableExecute(_requestTextChangeNotificationsForWindow, obj.appModule.helperLocalBindingHandle, obj.windowHandle, enable)
	if enable:
		_textChangeNotificationObjs.append(obj)
Exemple #10
0
	def getListGroupInfo(self,groupIndex):
		header=AutoFreeBSTR()
		footer=AutoFreeBSTR()
		state=c_int()
		if watchdog.cancellableExecute(NVDAHelper.localLib.nvdaInProcUtils_sysListView32_getGroupInfo,self.appModule.helperLocalBindingHandle,self.windowHandle,groupIndex,byref(header),byref(footer),byref(state))!=0:
			return None
		return dict(header=header.value,footer=footer.value,state=state.value,groupIndex=groupIndex)
Exemple #11
0
def getCaretRect(obj):
	left=c_long()
	top=c_long()
	right=c_long()
	bottom=c_long()
	res=watchdog.cancellableExecute(NVDAHelper.localLib.displayModel_getCaretRect, obj.appModule.helperLocalBindingHandle, obj.windowThreadID, byref(left),byref(top),byref(right),byref(bottom))
	if res!=0:
			raise RuntimeError("displayModel_getCaretRect failed with res %d"%res)
	return RECT(left,top,right,bottom)
Exemple #12
0
def getCaretRect(obj):
	left=c_long()
	top=c_long()
	right=c_long()
	bottom=c_long()
	res=watchdog.cancellableExecute(NVDAHelper.localLib.displayModel_getCaretRect, obj.appModule.helperLocalBindingHandle, obj.windowThreadID, byref(left),byref(top),byref(right),byref(bottom))
	if res!=0:
			raise RuntimeError("displayModel_getCaretRect failed with res %d"%res)
	return RECT(left,top,right,bottom)
Exemple #13
0
def getWindowTextInRect(bindingHandle, windowHandle, left, top, right, bottom,minHorizontalWhitespace,minVerticalWhitespace,stripOuterWhitespace=True,includeDescendantWindows=True):
	text, cpBuf = watchdog.cancellableExecute(_getWindowTextInRect, bindingHandle, windowHandle, includeDescendantWindows, left, top, right, bottom,minHorizontalWhitespace,minVerticalWhitespace,stripOuterWhitespace)
	if not text or not cpBuf:
		return u"",[]

	characterLocations = []
	cpBufIt = iter(cpBuf)
	for cp in cpBufIt:
		characterLocations.append((ord(cp), ord(next(cpBufIt)), ord(next(cpBufIt)), ord(next(cpBufIt))))
	return text, characterLocations
Exemple #14
0
 def _getColumnContentRaw(self, index):
     item = self.IAccessibleChildID - 1
     subItem = index
     text = AutoFreeBSTR()
     if watchdog.cancellableExecute(
             NVDAHelper.localLib.
             nvdaInProcUtils_sysListView32_getColumnContent,
             self.appModule.helperLocalBindingHandle, self.windowHandle,
             item, subItem, ctypes.byref(text)) != 0:
         return None
     return text.value
Exemple #15
0
	def _getColumnOrderArrayRaw(self, columnCount: int) -> Optional[ctypes.Array]:
		columnOrderArray = (ctypes.c_int * columnCount)()
		res = watchdog.cancellableExecute(
			NVDAHelper.localLib.nvdaInProcUtils_sysListView32_getColumnOrderArray,
			self.appModule.helperLocalBindingHandle,
			self.windowHandle,
			columnCount,
			columnOrderArray
		)
		if res:
			return None
		return columnOrderArray
Exemple #16
0
	def _getColumnHeaderRaw(self, index: int) -> Optional[str]:
		subItem = index
		text = AutoFreeBSTR()
		if watchdog.cancellableExecute(
			NVDAHelper.localLib.nvdaInProcUtils_sysListView32_getColumnHeader,
			self.appModule.helperLocalBindingHandle,
			self.windowHandle,
			subItem,
			ctypes.byref(text)
		) != 0:
			return None
		return text.value
def getCaretRect(obj):
    left = ctypes.c_long()
    top = ctypes.c_long()
    right = ctypes.c_long()
    bottom = ctypes.c_long()
    res = watchdog.cancellableExecute(
        NVDAHelper.localLib.displayModel_getCaretRect,
        obj.appModule.helperLocalBindingHandle, obj.windowThreadID,
        ctypes.byref(left), ctypes.byref(top), ctypes.byref(right),
        ctypes.byref(bottom))
    if res != 0:
        raise RuntimeError(f"displayModel_getCaretRect failed with res {res}")
    return RectLTRB(left.value, top.value, right.value, bottom.value)
Exemple #18
0
	def _getColumnLocationRaw(self, index: int) -> ctypes.wintypes.RECT:
		item = self.IAccessibleChildID - 1
		subItem = index
		rect = ctypes.wintypes.RECT()
		if watchdog.cancellableExecute(
			NVDAHelper.localLib.nvdaInProcUtils_sysListView32_getColumnLocation,
			self.appModule.helperLocalBindingHandle,
			self.windowHandle,
			item,
			subItem,
			ctypes.byref(rect)
		) != 0:
			return None
		return rect
Exemple #19
0
    def _getColumnHeaderRawInProc(self, index: int) -> Optional[str]:
        """Retrieves text of the header for the given column.
		Note that this method operates in process and cannot be used in situations where NVDA cannot inject
		i.e when running as a Windows Store application or when no focus event was received on startup.
		"""
        subItem = index
        text = AutoFreeBSTR()
        if watchdog.cancellableExecute(
                NVDAHelper.localLib.
                nvdaInProcUtils_sysListView32_getColumnHeader,
                self.appModule.helperLocalBindingHandle, self.windowHandle,
                subItem, ctypes.byref(text)) != 0:
            return None
        return text.value
Exemple #20
0
    def _getColumnLocationRawInProc(self, index: int) -> ctypes.wintypes.RECT:
        """Retrieves rectangle containing coordinates for a given column.
		Note that this method operates in process and cannot be used in situations where NVDA cannot inject
		i.e when running as a Windows Store application or when no focus event was received on startup.
		"""
        item = self.IAccessibleChildID - 1
        subItem = index
        rect = ctypes.wintypes.RECT()
        if watchdog.cancellableExecute(
                NVDAHelper.localLib.
                nvdaInProcUtils_sysListView32_getColumnLocation,
                self.appModule.helperLocalBindingHandle, self.windowHandle,
                item, subItem, ctypes.byref(rect)) != 0:
            return None
        return rect
Exemple #21
0
    def _getColumnOrderArrayRawInProc(
            self, columnCount: int) -> Optional[ctypes.Array]:
        """Retrieves a list of column indexes for a given list control.
		See `_getColumnOrderArrayRaw` for more comments.
		Note that this method operates in process and cannot be used in situations where NVDA cannot inject
		i.e when running as a Windows Store application or when no focus event was received on startup.
		"""
        columnOrderArray = (ctypes.c_int * columnCount)()
        res = watchdog.cancellableExecute(
            NVDAHelper.localLib.
            nvdaInProcUtils_sysListView32_getColumnOrderArray,
            self.appModule.helperLocalBindingHandle, self.windowHandle,
            columnCount, columnOrderArray)
        if res:
            return None
        return columnOrderArray
Exemple #22
0
def getWindowTextInRect(bindingHandle,
                        windowHandle,
                        left,
                        top,
                        right,
                        bottom,
                        minHorizontalWhitespace,
                        minVerticalWhitespace,
                        useXML=False):
    text, cpBuf = watchdog.cancellableExecute(_getWindowTextInRect,
                                              bindingHandle, windowHandle,
                                              left, top, right, bottom,
                                              minHorizontalWhitespace,
                                              minVerticalWhitespace, useXML)
    if not text or not cpBuf:
        return u"", []

    characterLocations = []
    cpBufIt = iter(cpBuf)
    for cp in cpBufIt:
        characterLocations.append(
            (ord(cp), ord(next(cpBufIt)), ord(next(cpBufIt)),
             ord(next(cpBufIt)), c_short(ord(next(cpBufIt))).value))
    return text, characterLocations