Re: Customize say all


Hi Alberto,

Here is a global plugin for the developer's scratchpad that should do the job you're asking for.

When UIA is enabled in the settings for Word or Microsoft Edge, the method to extend for text is _getTextFromUIARange.

In other situations, it's _getTextRange.

With this example, sentences like "table of contents" should be replaced by "table contents".

This type of practice is not highly recommended, as it changes NVDA's internal behavior when reading text.

The module still has some imperfections, it works fine in Word when UIA is enabled, but I haven't yet added the lines to make it work when UIA is not enabled in Word only.

Otherwise, in browsers it has been tested with Microsoft Edge with UIA enabled and disabled, Google Chrome and Firefox, not tested with Internet Explorer.

It should also work in Mozilla Thunderbird, notepad and notepad++.

Sometimes lines indicating that some unreachable objects have been deleted appear in the log.

I haven't fully commented on it, but I think you should understand the different instructions well.

Hope this helps.

Kind regards,

Le 11/08/2022 à 11:24, Alberto Buffolino a écrit :
Il 11/08/2022 11.02, Abdel ha scritto:
There are classes that inherit from the treeInterceptorHandler.TreeInterceptor class that add extra features.
If we stick with this logic, these extra features are not considered and we always extend the features present in the treeInterceptorHandler.TreeInterceptor class.
Hi Abdel,
I think it's exactly my problem, but with TextInfo.
Let it be clear that we just discuss about coding and object oriented programming, not about personal solutions if they work.
Anyway, I discovered in last days I have messed up  the NVDA object and its TextInfo instance, and for the moment I partially solved operating over TextInfo instance only, and patching the _getTextRange method with a new module method, so:
originalFunc = None

def getPartialObj(obj):
    global originalFunc
    originalFunc = obj._getTextRange
    obj._getTextRange = _getPartialTextRange
    return obj

def _getPartialTextRange(self, *args, **kwargs):
    tempText = originalFunc(self, *args, **kwargs)"TempText: %s"%tempText)
    newText = ' '.join(filter(lambda i: len(i)>=4, tempText.split(" ")))"NewText: %s"%newText)
    return newText
It works now, but only in simple text editor like notepad and notepad++. I must study a bit more the various mechanisms involved (getTextWithFields, maybe) to cover also Word and browsers, for example.

Join { to automatically receive all group messages.