Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback: https://github.com/nvdaes/placeMarkers/pull/39Cheers.
|
|
toggle quoted message
Show quoted text
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Thanks guys. This is much appreciated.
toggle quoted message
Show quoted text
-----Original Message----- From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To: nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA Hi again: Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here: https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addonComments are appreciated. 2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>: Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's
really necessary.
Finally, you just need to store the startOffset and optionally the
endOffset, which can be done very well in a simple text file or
using json.
Weakly referenced objects can be stored with the third party dill
module,, take
a look here, but again, it's not really necessary.
To hit the marker,
focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset,
endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the
textInfos objects, from first position, using the unit per
character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you
think.
Kind regards,
Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a
écrit :
toggle quoted message
Show quoted text
Thanks guys. This is much appreciated.
-----Original Message-----
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz
Sent: Tuesday, July 12, 2022 12:19 AM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request.
Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io
<nrm1977@...>:
Hi:
I've used code provided by Abdel to make possible to save bookmarks
with UIA in browsers based on Chromium. Anyway, we cannot nove to
bookmarks with UIA enabled in those browsers since bookmarks seems to
be stored in wekrefobjects that cannot be pickled, and they haven't
startOffset attribute. But UIA, by default, is enabled for these
browsers just when needed, and it canbe always enabled using advanced
settings, which shouldn't be changed unless we have a specific
purpose, but not in general.
So I have handled the exception produced when tryting t go to a
bookmark in such cases, providing a message (spoken and breilled, with
ui.message function), indicating : "Cannot move to bookmark with UIA
enabled for your browser". I have thought about creating a profile to
disable UIA before moving to bookmarks and reenable it later, but,
since this is an advanced option and it's not recommended to change it
in general, I think this can be an acceptable solution.
Anyway, before mergint this pull request, I comment this here in case
someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
toggle quoted message
Show quoted text
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Hi dear Noelia and all,
You wrote:
the move method don't work well in all
case.
You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with
UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler
import NVDAObjects
def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool:
"""
Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings.
The operation should be initiated from the first position of the textInfo object.
@Parameters:
@param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation.
@type obj: L{NVDAObjects.NVDAObject}.
@param startOffset: The offset value towards which we want to perform the movement.
@type startOffset: int.
@returns: A boolean confirming the operation.
@rtype: bool.
"""
# We store the first position.
first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST)
# We perform a first move with the MoveEndPointByUnit method.
first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End, UIAHandler.TextUnit_Character, startOffset)
# As the move may not reach the correct offset, we make some small adjustments.
if len(first.text) > startOffset:
first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End, UIAHandler.TextUnit_Character, - (len(first.text) - startOffset))
if startOffset > len(first.text):
first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End, UIAHandler.TextUnit_Character, startOffset - len(first.text))
if len(first.text) == startOffset:
first.collapse(True)
obj.treeInterceptor._set_selection(first)
return True
return False
If you want, you can test it in NVDA's Python console, with the
user guide of NVDA, English version.
With an installed version of NVDA, The file is located at
"file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position
the cursor at the very beginning of the document with Control +
Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as
follows:
goToBookmark (focus, 208724)
Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards,
Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a
écrit :
Hi dear Abdel, the move method don't work well in all case. You can
test with the NVDA user guide using Edge with UIA enabled and trying
to move to the end of the large document.
Please see this issue. I created the add-on using the moved method,
but then I needed to switch to testInfo.bookmark.
But I¡ll try the dill module! And of course, when I can I'll create a
post on the NVDA¡s website maintained by me and other members of
spanish community, members of a groups.io mailing list, thanking you
for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's
really necessary.
Finally, you just need to store the startOffset and optionally the
endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill
module,, take a look here
<https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>,
but again, it's not really necessary.
To hit the marker,
focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset,
endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos
objects, from first position, using the unit per character and the
number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards,
Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message-----
From:nvda-addons@nvda-addons.groups.io
<nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz
Sent: Tuesday, July 12, 2022 12:19 AM
To:nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks
with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with
GitHub Actions after merging the pull request.
Probably I'll release version 21.0 the next weekend as stable if no bug is
reported, considering that it has been tested and code comes from Abdel
after investigation and testing. The add-on attached to the current
Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io
<nrm1977@...>:
Hi:
I've used code provided by Abdel to make possible to save bookmarks
with UIA in browsers based on Chromium. Anyway, we cannot nove to
bookmarks with UIA enabled in those browsers since bookmarks seems to
be stored in wekrefobjects that cannot be pickled, and they haven't
startOffset attribute. But UIA, by default, is enabled for these
browsers just when needed, and it canbe always enabled using advanced
settings, which shouldn't be changed unless we have a specific
purpose, but not in general.
So I have handled the exception produced when tryting t go to a
bookmark in such cases, providing a message (spoken and breilled, with
ui.message function), indicating : "Cannot move to bookmark with UIA
enabled for your browser". I have thought about creating a profile to
disable UIA before moving to bookmarks and reenable it later, but,
since this is an advanced option and it's not recommended to change it
in general, I think this can be an acceptable solution.
Anyway, before mergint this pull request, I comment this here in case
someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you: https://github.com/nvdaes/placeMarkersSee you soon! 2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
toggle quoted message
Show quoted text
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
toggle quoted message
Show quoted text
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit : Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Many thanks, dear Abdel. Please update the readme and feel free to add yourself in the copyright or as an author if you want.
2022-07-20 15:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
toggle quoted message
Show quoted text
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit :
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
toggle quoted message
Show quoted text
Le 20/07/2022 à 15:23, Noelia Ruiz a écrit : Many thanks, dear Abdel. Please update the readme and feel free to add yourself in the copyright or as an author if you want.
2022-07-20 15:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit :
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Hi again Noelia,
I haven't modified the documentation, nor added my name among the contributors.
You can do it if you want, when the add-on is declared stable.
Kind regards, Abdel.
toggle quoted message
Show quoted text
Le 20/07/2022 à 18:28, Abdel a écrit : Hi dear Noelia,
I just created the Pull Request.
You'll find it here:
https://github.com/nvdaes/placeMarkers/pull/41
I changed the version to 22.0-dev for testing.
Tell me what you think about it.
Kind regards, Abdel.
Le 20/07/2022 à 15:23, Noelia Ruiz a écrit :
Many thanks, dear Abdel. Please update the readme and feel free to add yourself in the copyright or as an author if you want.
2022-07-20 15:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit :
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Hi again Noelia,
I just updated my PR comment using the template.
Kind regards, Abdel.
toggle quoted message
Show quoted text
Le 20/07/2022 à 18:32, Abdel a écrit : Hi again Noelia,
I haven't modified the documentation, nor added my name among the contributors.
You can do it if you want, when the add-on is declared stable.
Kind regards, Abdel.
Le 20/07/2022 à 18:28, Abdel a écrit :
Hi dear Noelia,
I just created the Pull Request.
You'll find it here:
https://github.com/nvdaes/placeMarkers/pull/41
I changed the version to 22.0-dev for testing.
Tell me what you think about it.
Kind regards, Abdel.
Le 20/07/2022 à 15:23, Noelia Ruiz a écrit :
Many thanks, dear Abdel. Please update the readme and feel free to add yourself in the copyright or as an author if you want.
2022-07-20 15:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit :
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Hi again Abdel: I"ll test the artifact generated with GitHub Actions (the .nvda-addon binary) and, if all is right, I"ll add your namein the readme.md and in the copyright of the .py file. Authors are just people who add their email address for support, and you can do it if you want now or later, of course. Many thanks. As always, I"m pleased contributing with you.
Enviado desde mi iPhone
toggle quoted message
Show quoted text
El 20 jul 2022, a las 19:01, Abdel <abdelkrim.bensaid@...> escribió:
Hi again Noelia,
I just updated my PR comment using the template.
Kind regards, Abdel.
Le 20/07/2022 à 18:32, Abdel a écrit : Hi again Noelia,
I haven't modified the documentation, nor added my name among the contributors.
You can do it if you want, when the add-on is declared stable.
Kind regards, Abdel.
Le 20/07/2022 à 18:28, Abdel a écrit : Hi dear Noelia,
I just created the Pull Request.
You'll find it here:
https://github.com/nvdaes/placeMarkers/pull/41
I changed the version to 22.0-dev for testing.
Tell me what you think about it.
Kind regards, Abdel.
Le 20/07/2022 à 15:23, Noelia Ruiz a écrit :
Many thanks, dear Abdel. Please update the readme and feel free to add yourself in the copyright or as an author if you want.
2022-07-20 15:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit :
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
No worries Noelia,
If you want, you can add me as a contributor on the placeMarkers GitHub repo, I'm not part of it yet.
Thanks in advance.
Kind regards, Abdel.
toggle quoted message
Show quoted text
Le 20/07/2022 à 19:26, Noelia Ruiz a écrit : Hi again Abdel: I"ll test the artifact generated with GitHub Actions (the .nvda-addon binary) and, if all is right, I"ll add your namein the readme.md and in the copyright of the .py file. Authors are just people who add their email address for support, and you can do it if you want now or later, of course. Many thanks. As always, I"m pleased contributing with you.
Enviado desde mi iPhone
El 20 jul 2022, a las 19:01, Abdel <abdelkrim.bensaid@...> escribió:
Hi again Noelia,
I just updated my PR comment using the template.
Kind regards, Abdel.
Le 20/07/2022 à 18:32, Abdel a écrit : Hi again Noelia,
I haven't modified the documentation, nor added my name among the contributors.
You can do it if you want, when the add-on is declared stable.
Kind regards, Abdel.
Le 20/07/2022 à 18:28, Abdel a écrit : Hi dear Noelia,
I just created the Pull Request.
You'll find it here:
https://github.com/nvdaes/placeMarkers/pull/41
I changed the version to 22.0-dev for testing.
Tell me what you think about it.
Kind regards, Abdel.
Le 20/07/2022 à 15:23, Noelia Ruiz a écrit :
Many thanks, dear Abdel. Please update the readme and feel free to add yourself in the copyright or as an author if you want.
2022-07-20 15:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit :
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
I'll add you as a collaborator, and if you want to be added as an author you can edit buildVars.py. I try to create pull requests except for minor changes so that GitHub Actions make his work for example checking if all translatable strings have comments for translators or checking for problematic BOM characters, thanks to Mesar, the creator of the NVDA's translations system and other contributions, who created this workflow. Some workflows (.yaml files) can be run on push event, but other ones just in PRs. I understand that using a template maybe tricky for some people, but I've closed pull requests or they haven't been successful since sometimes I didn't understand the purpose or the intention of people who opened them, so I decided to include a template and also checks. I may do it during the weekend or before, deppending of weather since I cannot work if it's too hot and tomorrow I'll receive another vaccine against COVID, so I may need a rest during some hours or a day or so. No worries if this takes some days to be completed. Thanks
2022-07-20 19:56 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
toggle quoted message
Show quoted text
No worries Noelia,
If you want, you can add me as a contributor on the placeMarkers GitHub repo, I'm not part of it yet.
Thanks in advance.
Kind regards, Abdel.
Le 20/07/2022 à 19:26, Noelia Ruiz a écrit :
Hi again Abdel: I"ll test the artifact generated with GitHub Actions (the .nvda-addon binary) and, if all is right, I"ll add your namein the readme.md and in the copyright of the .py file. Authors are just people who add their email address for support, and you can do it if you want now or later, of course. Many thanks. As always, I"m pleased contributing with you.
Enviado desde mi iPhone
El 20 jul 2022, a las 19:01, Abdel <abdelkrim.bensaid@...> escribió:
Hi again Noelia,
I just updated my PR comment using the template.
Kind regards, Abdel.
Le 20/07/2022 à 18:32, Abdel a écrit : Hi again Noelia,
I haven't modified the documentation, nor added my name among the contributors.
You can do it if you want, when the add-on is declared stable.
Kind regards, Abdel.
Le 20/07/2022 à 18:28, Abdel a écrit : Hi dear Noelia,
I just created the Pull Request.
You'll find it here:
https://github.com/nvdaes/placeMarkers/pull/41
I changed the version to 22.0-dev for testing.
Tell me what you think about it.
Kind regards, Abdel.
Le 20/07/2022 à 15:23, Noelia Ruiz a écrit :
Many thanks, dear Abdel. Please update the readme and feel free to add yourself in the copyright or as an author if you want.
2022-07-20 15:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit :
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|
Thanks dear Noelia,
You can do this whenever you want, there's no rush.
Kind regards, Abdel.
toggle quoted message
Show quoted text
Le 20/07/2022 à 20:04, Noelia Ruiz a écrit : I'll add you as a collaborator, and if you want to be added as an author you can edit buildVars.py. I try to create pull requests except for minor changes so that GitHub Actions make his work for example checking if all translatable strings have comments for translators or checking for problematic BOM characters, thanks to Mesar, the creator of the NVDA's translations system and other contributions, who created this workflow. Some workflows (.yaml files) can be run on push event, but other ones just in PRs. I understand that using a template maybe tricky for some people, but I've closed pull requests or they haven't been successful since sometimes I didn't understand the purpose or the intention of people who opened them, so I decided to include a template and also checks. I may do it during the weekend or before, deppending of weather since I cannot work if it's too hot and tomorrow I'll receive another vaccine against COVID, so I may need a rest during some hours or a day or so. No worries if this takes some days to be completed. Thanks
2022-07-20 19:56 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
No worries Noelia,
If you want, you can add me as a contributor on the placeMarkers GitHub repo, I'm not part of it yet.
Thanks in advance.
Kind regards, Abdel.
Le 20/07/2022 à 19:26, Noelia Ruiz a écrit :
Hi again Abdel: I"ll test the artifact generated with GitHub Actions (the .nvda-addon binary) and, if all is right, I"ll add your namein the readme.md and in the copyright of the .py file. Authors are just people who add their email address for support, and you can do it if you want now or later, of course. Many thanks. As always, I"m pleased contributing with you.
Enviado desde mi iPhone
El 20 jul 2022, a las 19:01, Abdel <abdelkrim.bensaid@...> escribió:
Hi again Noelia,
I just updated my PR comment using the template.
Kind regards, Abdel.
Le 20/07/2022 à 18:32, Abdel a écrit : Hi again Noelia,
I haven't modified the documentation, nor added my name among the contributors.
You can do it if you want, when the add-on is declared stable.
Kind regards, Abdel.
Le 20/07/2022 à 18:28, Abdel a écrit : Hi dear Noelia,
I just created the Pull Request.
You'll find it here:
https://github.com/nvdaes/placeMarkers/pull/41
I changed the version to 22.0-dev for testing.
Tell me what you think about it.
Kind regards, Abdel.
Le 20/07/2022 à 15:23, Noelia Ruiz a écrit :
Many thanks, dear Abdel. Please update the readme and feel free to add yourself in the copyright or as an author if you want.
2022-07-20 15:05 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi again Noelia,
I think I'll be able to make the PR on placeMarkers repo for compatibility with Edge using UIA feature.
I propose to do it in the week, it shouldn't be very difficult to implement, your add-ons are always very clear for the developers.
I think I will keep using the pickle module, as you started with it.
Object storage with pickle can still be done, you can compare the changes on GitHub if you want, before accepting the PR merge.
In fact, it's not weakly referenced objects that are stored, but dictionary objects, so there's no problem.
See you soon for the PR.
Kind regards, Abdel.
Le 19/07/2022 à 08:44, Noelia Ruiz a écrit :
Hi dear Abdel, many thanks for your advice! Yesterday I published placeMarkers 21.1, since I made a mistake in 21.0, and this was approved by Joseph to be included on the website. Today I've writen a post to aknowledge your advice, very short and without mentioning all your contributions: https://nvdaes.github.io/abdel/
I'll test this to release 2022.0 of placeMarkers with ability to go to bookmarks with UIA in Edge. Anyway, if you are comfortable creating a PR on the placeMarkers repo, your contribution will be automatically listed in release changes. Otherwise I'll do for you:
https://github.com/nvdaes/placeMarkers
See you soon!
2022-07-19 8:10 GMT+02:00, Abdel <abdelkrim.bensaid@...>:
Hi dear Noelia and all,
You wrote:
the move method don't work well in all case. You're right, but fortunately there are other solutions.
After seeing together how to find the offset of a bookmark with UIA feature enabled, I have good news for you.
Here's a function that should get the job done pretty quickly.
import UIAHandler import NVDAObjects def goToBookmark (obj: NVDAObjects.NVDAObject, startOffset: int) -> bool: """ Allows to move the start browse mode textInfo endPoint to the location where the offset position passed in parameter is located with Microsoft Edge, hen UIA feature is enabled in NVDA advanced settings. The operation should be initiated from the first position of the textInfo object. @Parameters: @param obj: The NVDA object representing the web page in which we want to perform the cursor movement operation. @type obj: L{NVDAObjects.NVDAObject}. @param startOffset: The offset value towards which we want to perform the movement. @type startOffset: int. @returns: A boolean confirming the operation. @rtype: bool. """ # We store the first position. first = focus.treeInterceptor.makeTextInfo(textInfos.POSITION_FIRST) # We perform a first move with the MoveEndPointByUnit method. first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset) # As the move may not reach the correct offset, we make some small adjustments. if len(first.text) > startOffset: first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, - (len(first.text) - startOffset)) if startOffset > len(first.text): first._rangeObj.MoveEndpointByUnit(UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.TextUnit_Character, startOffset - len(first.text)) if len(first.text) == startOffset: first.collapse(True) obj.treeInterceptor._set_selection(first) return True return False If you want, you can test it in NVDA's Python console, with the user guide of NVDA, English version.
With an installed version of NVDA, The file is located at "file:///C:/Program%20Files%20(x86)/NVDA/documentation/en/userGuide.html".
This done, to reach the last word of the document, first position the cursor at the very beginning of the document with Control + Home.
The word is "development".
The first character of this word is located at offset 208724.
Next, open NVDA's Python console with NVDA + Control + §Z.
Once done, paste the code above.
Then press enter several times, then execute the function as follows:
goToBookmark (focus, 208724) Tell me if you reach the word correctly, here it works very well.
The waiting time is very short.
Hope this helps.
Kind regards, Abdel.
Le 15/07/2022 à 14:12, Noelia Ruiz a écrit :
Hi dear Abdel, the move method don't work well in all case. You can test with the NVDA user guide using Edge with UIA enabled and trying to move to the end of the large document. Please see this issue. I created the add-on using the moved method, but then I needed to switch to testInfo.bookmark. But I¡ll try the dill module! And of course, when I can I'll create a post on the NVDA¡s website maintained by me and other members of spanish community, members of a groups.io mailing list, thanking you for your advice, in particular for the placemarkers add-on.
2022-07-15 14:05 GMT+02:00, Abdel<abdelkrim.bensaid@...>:
Hi dear Noelia and all,
Thanks for this PlaceMarkers addon update.
Regarding storing bookmark objects with pickle, I don't think it's really necessary.
Finally, you just need to store the startOffset and optionally the endOffset, which can be done very well in a simple text file or using json.
Weakly referenced objects can be stored with the third party dill module,, take a look here <https://stackoverflow.com/questions/23644920/pickling-weakref-in-python>, but again, it's not really necessary.
To hit the marker, focus.treeInterceptor.makeTextInfo(textInfos.offsets.Offsets(startOffset, endOffset)) works fine when UIA is not used.
However, when UIA is used, we only have the move method of the textInfos objects, from first position, using the unit per character and the number of offsets as the second parameter.
After that, info.updateCaret() should do the trick.
It seems to work well after sevral tests, I don't know what you think.
Kind regards, Abdel.
Le 13/07/2022 à 04:19, Roberto Perez a écrit :
Thanks guys. This is much appreciated.
-----Original Message----- From:nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Noelia Ruiz Sent: Tuesday, July 12, 2022 12:19 AM To:nvda-addons@nvda-addons.groups.io Subject: Re: [nvda-addons] placeMarkers with ability to save bookmarks with UIA
Hi again:
Here's the Development Build prerelease, generated automatically with GitHub Actions after merging the pull request. Probably I'll release version 21.0 the next weekend as stable if no bug is reported, considering that it has been tested and code comes from Abdel after investigation and testing. The add-on attached to the current Development Build can be download here:
https://github.com/nvdaes/placeMarkers/releases/download/latest/placeMarkers-f2226b64e8bbe5643d985e81af5015f3dc86834e.nvda-addon
Comments are appreciated.
2022-07-10 17:59 GMT+02:00, Noelia Ruiz via groups.io <nrm1977@...>:
Hi: I've used code provided by Abdel to make possible to save bookmarks with UIA in browsers based on Chromium. Anyway, we cannot nove to bookmarks with UIA enabled in those browsers since bookmarks seems to be stored in wekrefobjects that cannot be pickled, and they haven't startOffset attribute. But UIA, by default, is enabled for these browsers just when needed, and it canbe always enabled using advanced settings, which shouldn't be changed unless we have a specific purpose, but not in general. So I have handled the exception produced when tryting t go to a bookmark in such cases, providing a message (spoken and breilled, with ui.message function), indicating : "Cannot move to bookmark with UIA enabled for your browser". I have thought about creating a profile to disable UIA before moving to bookmarks and reenable it later, but, since this is an advanced option and it's not recommended to change it in general, I think this can be an acceptable solution. Anyway, before mergint this pull request, I comment this here in case someone wants to provide feedback:
https://github.com/nvdaes/placeMarkers/pull/39
Cheers.
|
|