Topics

Plugin Help please!

Nathaniel Schmidt
 

Hi all,

 

If anyone can help, I would be grateful.  I am currently trying to update some plugin code I wrote the bulk of back in 2011, periodically updating it with a couple of other contributors up until about 2014.  I am hoping to ultimately package it as an addon and submit it to the community page, in the hope that people may find it useful.  I stopped coding while I was doing undergrad studies so I am a bit out-of-practice.  The plugin used to work with earlier versions of NVDA but no longer does.  In the past it has been used by at least two other people that I know of apart from myself (one of them may still be on the nvda-dev mailing list), so I feel that it may be a reasonable coding courtesy to try to update the code as much as possible, though it is no longer useful to me personally.  So won't be too worried if problems cannot be overcome.  FYI, I am using Windows 10 with NVDA 2019.2.1, Python 3.8 and comtypes 1.1.7.

 

The plugin was initially a global plugin (an admittedly sloppy but superficially convenient choice for its purposes) that would use registered COM objects, allowing Windows screen-readers to communicate with a cross-platform Python package called Latex-Access, developed by Alastair Irving at http://latex-access.sourceforge.net/.  The package's main purpose is to translate lines of LaTeX syntax into Nemeth and UEB Braille, as well as speech, making it quicker and easier to read and understand equations and expressions.  It also contains a matrix browser for viewing matrices in a table-like fashion.  In addition, it contains a preprocessor for interpreting and expressing custom-defined LaTeX expressions.  It would be somewhat useful for those studying, or teaching, mathematics at a secondary or tertiary educational level and who use the LaTeX document preparation system for their work, or reviewing the work of others.

 

The final checked-out file in Subversion is not up-to-date, as the project manager seems to have potentially gone off the grid and I can no longer remember the password to my old SourceForge account attached to my old email, so I am unable to make commits.  So a Dropbox link is below:

https://www.dropbox.com/s/a5qqiu6abgu7ekn/notepad.py?dl=0

 

The plugin is in the process of being ported from a global plugin to an app module, which an end-user should be able to rename at their leisure, to the executable file of any text-editor of their choice.  This should mostly be a smooth transition in each instance, as the scripts are designed to work within accessible edit controls.  Currently the plugin only supports controls which notify of text selection changes but this could be altered in future.  I realise that some of the key bindings are likely to clash with commands from other editors; I am happy to change them for the community but for now, the primary desire has been to stick with the conventions subjectively, implicitly set out by the project manager who wrote the JAWS scripts.  To keep things simple, I have set the appModule to use notepad.

 

The problem currently at the forefront is unintended and unexplained triggering of scripts.  One in particular, "script_inputMatrix", is causing havoc by being triggered by just about every possible keypress relevant to typing input and I am struggling to trace the exact cause of the problem.  The debug log output is as follows:

 

---Start---

IO - inputCore.InputManager.executeGesture (15:46:18.426):

Input: kb(laptop):control+m

ERROR - core.CorePump.run (15:46:18.454):

errors in this core pump cycle

Traceback (most recent call last):

  File "core.pyo", line 489, in run

  File "IAccessibleHandler.pyo", line 903, in pumpAll

  File "IAccessibleHandler.pyo", line 620, in processGenericWinEvent

  File "appModuleHandler.pyo", line 134, in update

  File "appModuleHandler.pyo", line 119, in getAppModuleFromProcessID

  File "appModuleHandler.pyo", line 97, in getAppNameFromProcessID

  File "C:\Users\natha\AppData\Roaming\nvda\scratchpad\appModules\notepad.py", line 190

    ui.message (_(msg))

     ^

SyntaxError: invalid syntax

DEBUGWARNING - NVDAObjects.UIA.UIA._prefetchUIACacheForPropertyIDs (15:46:19.369):

IUIAutomationElement.buildUpdatedCache failed given IDs of set([30019, 30022, 30086, 30025, 30036, 30070, 30103, 30008, 30009, 30010, 30046, 30079])

---End---

 

Sometimes the same error repeats twice with only one keypress but I have no idea why.  I have two questions resulting from this output:

 

(1) What, precisely, is the syntax error? I feel stupid in asking but I can't figure it out.  I’m sure it's probably right in front of me.  The only thing that springs to mind is that maybe the gettext function has trouble with the explicit call to the str class, forcing some integers to be converted to strings but that is not exactly a syntax error.

 

(2) The general flow of the debug log (especially consecutive occurrences of the same error after general input and output) tells me that the script in question is being categorically triggered after just about every keypress.  How and why could this be happening? Is there something wrong in the appModules subclass method of EditableText._caretScriptPostMovedHelper? I fully realise that python does not call methods of the same name in bass classes unless the subclass explicitly calls them; however, I do not see how this makes a difference in this instance because I have rehashed all of the code anyway and have placed my own code inside it.

 

Is anyone willing or able to help me with this dilemma? If anyone wants to use the latex-access scripts with Python 3 then in order to register the COM objects, you will have to go into preprocessor.py and enclose the statement "import cPickle as pickle" with the following:

---Start---

try:

                import cPickle as pickle

except:

                import pickle

---End---

Python 3 tries to automatically load the accelerator module first so one cannot explicitly call the faster module written in C.

 

Also, as an aside, I know that Braille support is currently rather primitive.  I don’t really understand the brailleHandler code at the moment, so my capacity to manipulate its data is quite limited.

 

Thanks in advance and kind regards,

 

Nathaniel Schmidt

 

Hi,

Derek, any thoughts?

As for global plugin versus app module approach, if it will be used in edit fields across app modules, I think it would be best to package it as a global plugin.

Cheers,

Joseph

 

From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Nathaniel Schmidt
Sent: Tuesday, November 5, 2019 3:23 AM
To: nvda-addons@nvda-addons.groups.io
Subject: [nvda-addons] Plugin Help please!

 

Hi all,

 

If anyone can help, I would be grateful.  I am currently trying to update some plugin code I wrote the bulk of back in 2011, periodically updating it with a couple of other contributors up until about 2014.  I am hoping to ultimately package it as an addon and submit it to the community page, in the hope that people may find it useful.  I stopped coding while I was doing undergrad studies so I am a bit out-of-practice.  The plugin used to work with earlier versions of NVDA but no longer does.  In the past it has been used by at least two other people that I know of apart from myself (one of them may still be on the nvda-dev mailing list), so I feel that it may be a reasonable coding courtesy to try to update the code as much as possible, though it is no longer useful to me personally.  So won't be too worried if problems cannot be overcome.  FYI, I am using Windows 10 with NVDA 2019.2.1, Python 3.8 and comtypes 1.1.7.

 

The plugin was initially a global plugin (an admittedly sloppy but superficially convenient choice for its purposes) that would use registered COM objects, allowing Windows screen-readers to communicate with a cross-platform Python package called Latex-Access, developed by Alastair Irving at http://latex-access.sourceforge.net/.  The package's main purpose is to translate lines of LaTeX syntax into Nemeth and UEB Braille, as well as speech, making it quicker and easier to read and understand equations and expressions.  It also contains a matrix browser for viewing matrices in a table-like fashion.  In addition, it contains a preprocessor for interpreting and expressing custom-defined LaTeX expressions.  It would be somewhat useful for those studying, or teaching, mathematics at a secondary or tertiary educational level and who use the LaTeX document preparation system for their work, or reviewing the work of others.

 

The final checked-out file in Subversion is not up-to-date, as the project manager seems to have potentially gone off the grid and I can no longer remember the password to my old SourceForge account attached to my old email, so I am unable to make commits.  So a Dropbox link is below:

https://www.dropbox.com/s/a5qqiu6abgu7ekn/notepad.py?dl=0

 

The plugin is in the process of being ported from a global plugin to an app module, which an end-user should be able to rename at their leisure, to the executable file of any text-editor of their choice.  This should mostly be a smooth transition in each instance, as the scripts are designed to work within accessible edit controls.  Currently the plugin only supports controls which notify of text selection changes but this could be altered in future.  I realise that some of the key bindings are likely to clash with commands from other editors; I am happy to change them for the community but for now, the primary desire has been to stick with the conventions subjectively, implicitly set out by the project manager who wrote the JAWS scripts.  To keep things simple, I have set the appModule to use notepad.

 

The problem currently at the forefront is unintended and unexplained triggering of scripts.  One in particular, "script_inputMatrix", is causing havoc by being triggered by just about every possible keypress relevant to typing input and I am struggling to trace the exact cause of the problem.  The debug log output is as follows:

 

---Start---

IO - inputCore.InputManager.executeGesture (15:46:18.426):

Input: kb(laptop):control+m

ERROR - core.CorePump.run (15:46:18.454):

errors in this core pump cycle

Traceback (most recent call last):

  File "core.pyo", line 489, in run

  File "IAccessibleHandler.pyo", line 903, in pumpAll

  File "IAccessibleHandler.pyo", line 620, in processGenericWinEvent

  File "appModuleHandler.pyo", line 134, in update

  File "appModuleHandler.pyo", line 119, in getAppModuleFromProcessID

  File "appModuleHandler.pyo", line 97, in getAppNameFromProcessID

  File "C:\Users\natha\AppData\Roaming\nvda\scratchpad\appModules\notepad.py", line 190

    ui.message (_(msg))

     ^

SyntaxError: invalid syntax

DEBUGWARNING - NVDAObjects.UIA.UIA._prefetchUIACacheForPropertyIDs (15:46:19.369):

IUIAutomationElement.buildUpdatedCache failed given IDs of set([30019, 30022, 30086, 30025, 30036, 30070, 30103, 30008, 30009, 30010, 30046, 30079])

---End---

 

Sometimes the same error repeats twice with only one keypress but I have no idea why.  I have two questions resulting from this output:

 

(1) What, precisely, is the syntax error? I feel stupid in asking but I can't figure it out.  I’m sure it's probably right in front of me.  The only thing that springs to mind is that maybe the gettext function has trouble with the explicit call to the str class, forcing some integers to be converted to strings but that is not exactly a syntax error.

 

(2) The general flow of the debug log (especially consecutive occurrences of the same error after general input and output) tells me that the script in question is being categorically triggered after just about every keypress.  How and why could this be happening? Is there something wrong in the appModules subclass method of EditableText._caretScriptPostMovedHelper? I fully realise that python does not call methods of the same name in bass classes unless the subclass explicitly calls them; however, I do not see how this makes a difference in this instance because I have rehashed all of the code anyway and have placed my own code inside it.

 

Is anyone willing or able to help me with this dilemma? If anyone wants to use the latex-access scripts with Python 3 then in order to register the COM objects, you will have to go into preprocessor.py and enclose the statement "import cPickle as pickle" with the following:

---Start---

try:

                import cPickle as pickle

except:

                import pickle

---End---

Python 3 tries to automatically load the accelerator module first so one cannot explicitly call the faster module written in C.

 

Also, as an aside, I know that Braille support is currently rather primitive.  I don’t really understand the brailleHandler code at the moment, so my capacity to manipulate its data is quite limited.

 

Thanks in advance and kind regards,

 

Nathaniel Schmidt

Lukasz Golonka
 

hello,
Regarding this part:


On Tue, 5 Nov 2019 22:22:58 +1100
"Nathaniel Schmidt" <schmidty2244@...> wrote:


(1) What, precisely, is the syntax error? I feel stupid in asking but I can't figure it out. I’m sure it's probably right in front of me.

You have one unneeded call to GetText in your code. It should be:
ui.message (msg)
All parts of it are marked as translatable above.

--
HTH
Lukasz

Nathaniel Schmidt
 

Hi Lukaz,

that does fix one of my issues. Thanks.

Nathaniel Schmidt

Sent from my iPhone 7

On 6 Nov 2019, at 7:09 am, Lukasz Golonka <wulfryk1@...> wrote:

hello,
Regarding this part:


On Tue, 5 Nov 2019 22:22:58 +1100
"Nathaniel Schmidt" <schmidty2244@...> wrote:


(1) What, precisely, is the syntax error? I feel stupid in asking but I can't figure it out. I’m sure it's probably right in front of me.

You have one unneeded call to GetText in your code. It should be:
ui.message (msg)
All parts of it are marked as translatable above.

--
HTH
Lukasz


Nathaniel Schmidt
 

Hi Joseph,

Your suggestion was initially my thinking as well.  However, there are a number of limitations to this approach:
Firstly, packaging the add-on as a global plug-in would significantly limit the possible keystrokes that could be used to attach to the scripts.  secondly, this means that the scripts and events would be able to be activated within any edit field within any Windows dialogue.  This is not practicable.  consequently, I think it would be much better to package the item as an app module, since it would then allow the end user to subjectively rename the file to which ever text editor they want to use.

Nathaniel Schmidt

7

On 6 Nov 2019, at 4:09 am, Joseph Lee <joseph.lee22590@...> wrote:



Hi,

Derek, any thoughts?

As for global plugin versus app module approach, if it will be used in edit fields across app modules, I think it would be best to package it as a global plugin.

Cheers,

Joseph

 

From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Nathaniel Schmidt
Sent: Tuesday, November 5, 2019 3:23 AM
To: nvda-addons@nvda-addons.groups.io
Subject: [nvda-addons] Plugin Help please!

 

Hi all,

 

If anyone can help, I would be grateful.  I am currently trying to update some plugin code I wrote the bulk of back in 2011, periodically updating it with a couple of other contributors up until about 2014.  I am hoping to ultimately package it as an addon and submit it to the community page, in the hope that people may find it useful.  I stopped coding while I was doing undergrad studies so I am a bit out-of-practice.  The plugin used to work with earlier versions of NVDA but no longer does.  In the past it has been used by at least two other people that I know of apart from myself (one of them may still be on the nvda-dev mailing list), so I feel that it may be a reasonable coding courtesy to try to update the code as much as possible, though it is no longer useful to me personally.  So won't be too worried if problems cannot be overcome.  FYI, I am using Windows 10 with NVDA 2019.2.1, Python 3.8 and comtypes 1.1.7.

 

The plugin was initially a global plugin (an admittedly sloppy but superficially convenient choice for its purposes) that would use registered COM objects, allowing Windows screen-readers to communicate with a cross-platform Python package called Latex-Access, developed by Alastair Irving at http://latex-access.sourceforge.net/.  The package's main purpose is to translate lines of LaTeX syntax into Nemeth and UEB Braille, as well as speech, making it quicker and easier to read and understand equations and expressions.  It also contains a matrix browser for viewing matrices in a table-like fashion.  In addition, it contains a preprocessor for interpreting and expressing custom-defined LaTeX expressions.  It would be somewhat useful for those studying, or teaching, mathematics at a secondary or tertiary educational level and who use the LaTeX document preparation system for their work, or reviewing the work of others.

 

The final checked-out file in Subversion is not up-to-date, as the project manager seems to have potentially gone off the grid and I can no longer remember the password to my old SourceForge account attached to my old email, so I am unable to make commits.  So a Dropbox link is below:

https://www.dropbox.com/s/a5qqiu6abgu7ekn/notepad.py?dl=0

 

The plugin is in the process of being ported from a global plugin to an app module, which an end-user should be able to rename at their leisure, to the executable file of any text-editor of their choice.  This should mostly be a smooth transition in each instance, as the scripts are designed to work within accessible edit controls.  Currently the plugin only supports controls which notify of text selection changes but this could be altered in future.  I realise that some of the key bindings are likely to clash with commands from other editors; I am happy to change them for the community but for now, the primary desire has been to stick with the conventions subjectively, implicitly set out by the project manager who wrote the JAWS scripts.  To keep things simple, I have set the appModule to use notepad.

 

The problem currently at the forefront is unintended and unexplained triggering of scripts.  One in particular, "script_inputMatrix", is causing havoc by being triggered by just about every possible keypress relevant to typing input and I am struggling to trace the exact cause of the problem.  The debug log output is as follows:

 

---Start---

IO - inputCore.InputManager.executeGesture (15:46:18.426):

Input: kb(laptop):control+m

ERROR - core.CorePump.run (15:46:18.454):

errors in this core pump cycle

Traceback (most recent call last):

  File "core.pyo", line 489, in run

  File "IAccessibleHandler.pyo", line 903, in pumpAll

  File "IAccessibleHandler.pyo", line 620, in processGenericWinEvent

  File "appModuleHandler.pyo", line 134, in update

  File "appModuleHandler.pyo", line 119, in getAppModuleFromProcessID

  File "appModuleHandler.pyo", line 97, in getAppNameFromProcessID

  File "C:\Users\natha\AppData\Roaming\nvda\scratchpad\appModules\notepad.py", line 190

    ui.message (_(msg))

     ^

SyntaxError: invalid syntax

DEBUGWARNING - NVDAObjects.UIA.UIA._prefetchUIACacheForPropertyIDs (15:46:19.369):

IUIAutomationElement.buildUpdatedCache failed given IDs of set([30019, 30022, 30086, 30025, 30036, 30070, 30103, 30008, 30009, 30010, 30046, 30079])

---End---

 

Sometimes the same error repeats twice with only one keypress but I have no idea why.  I have two questions resulting from this output:

 

(1) What, precisely, is the syntax error? I feel stupid in asking but I can't figure it out.  I’m sure it's probably right in front of me.  The only thing that springs to mind is that maybe the gettext function has trouble with the explicit call to the str class, forcing some integers to be converted to strings but that is not exactly a syntax error.

 

(2) The general flow of the debug log (especially consecutive occurrences of the same error after general input and output) tells me that the script in question is being categorically triggered after just about every keypress.  How and why could this be happening? Is there something wrong in the appModules subclass method of EditableText._caretScriptPostMovedHelper? I fully realise that python does not call methods of the same name in bass classes unless the subclass explicitly calls them; however, I do not see how this makes a difference in this instance because I have rehashed all of the code anyway and have placed my own code inside it.

 

Is anyone willing or able to help me with this dilemma? If anyone wants to use the latex-access scripts with Python 3 then in order to register the COM objects, you will have to go into preprocessor.py and enclose the statement "import cPickle as pickle" with the following:

---Start---

try:

                import cPickle as pickle

except:

                import pickle

---End---

Python 3 tries to automatically load the accelerator module first so one cannot explicitly call the faster module written in C.

 

Also, as an aside, I know that Braille support is currently rather primitive.  I don’t really understand the brailleHandler code at the moment, so my capacity to manipulate its data is quite limited.

 

Thanks in advance and kind regards,

 

Nathaniel Schmidt

Luke Davis
 

On Wed, 6 Nov 2019, Nathaniel Schmidt wrote:

 consequently, I think it would be much better to package the item as an app module, since it would then allow the end user to subjectively rename the file
to which ever text editor they want to use.
You are making two assumptions there which may not be safe:

First, that users will do the right thing in renaming the file or folder.
Second, that NVDA will retain the appModule name equals application name mechanism. There are already limited discussions underway about getting rid of that way of doing things. It won't make it into 2019.3 I would think, but I wouldn't be surprised to see it start happening in 2020.1.

You might consider making it a global plugin, and doing your keyboard interaction as an overlay. In other words, a two step process: one (remappable) key sequence to turn it on, followed by your own keys to do the reading or exploring or whatever.
Then you only have a single gesture in the global scope to worry about.

Where it makes sense, provide unassigned global gestures to do certain things, with the assumption that only advanced users will do that, but that most will use your overlay.

Luke

Nathaniel Schmidt
 

Hi Luke,

Thanks for the heads-up RE app modules:I was not aware of this. I am way behind the eight-ball as I have not kept up with NVDA development progress for about four years or so. I will take your suggestions into consideration and will probably endeavour to implement them.

Nathaniel Schmidt

Sent from my iPhone 7

On 6 Nov 2019, at 3:58 pm, Luke Davis <luke@...> wrote:

On Wed, 6 Nov 2019, Nathaniel Schmidt wrote:

consequently, I think it would be much better to package the item as an app module, since it would then allow the end user to subjectively rename the file
to which ever text editor they want to use.
You are making two assumptions there which may not be safe:

First, that users will do the right thing in renaming the file or folder.
Second, that NVDA will retain the appModule name equals application name mechanism. There are already limited discussions underway about getting rid of that way of doing things. It won't make it into 2019.3 I would think, but I wouldn't be surprised to see it start happening in 2020.1.

You might consider making it a global plugin, and doing your keyboard interaction as an overlay. In other words, a two step process: one (remappable) key sequence to turn it on, followed by your own keys to do the reading or exploring or whatever.
Then you only have a single gesture in the global scope to worry about.

Where it makes sense, provide unassigned global gestures to do certain things, with the assumption that only advanced users will do that, but that most will use your overlay.

Luke