Skip to content

Instantly share code, notes, and snippets.

@ShubhamJain7
Created August 22, 2020 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShubhamJain7/1503f6de291ebfbc99c54db64eff6c40 to your computer and use it in GitHub Desktop.
Save ShubhamJain7/1503f6de291ebfbc99c54db64eff6c40 to your computer and use it in GitHub Desktop.

Week 12

22 August, 2020

Hello again! I couldn't write a blog the previous week or even get much work done because I had exams. The most significant changes to the add-on were boiling down two gestures into one. Formerly, there were two separate gestures for getting results in the form of a spoken message and then in a virtual result window. It's much easier to have just a single gesture that you can press a different number of times instead of two since they do the same thing. Getting this functionality was frustratingly hard. Especially since I had worked with it before. Single vs. double gesture presses were used for filtering/not filtering non graphic elements before that was moved into the settings. NVDA's scriptHandler.py made it rather simple. All you had to do was call scriptHandler.getLastScriptRepeatCount() and do different things based on the value returned. So the code would look something like this:

scriptCount = scriptHandler.getLastScriptRepeatCount()
if scriptCount == 0:
    doDetectionAndSpeakResults()
else:
    doDetectionAndPresentResultsInAVirtualWindow()

It took me quite a while to figure out why this wasn't working like it had before. What I discovered was that the getLastScriptRepeatCount() method returns how many times the gesture was pressed in the last 0.5 seconds but with my code, the time difference was always greater than 0.5 seconds, no matter how quickly I pressed the gesture a second time. Infact, it was always around 1 to 2 seconds. The 0.5 second value was hardd-coded into the scriptHandler.py file so I ended up writing my own getScriptCount function as follows:

_lastCalled = 0
def getScriptCount():
	global _lastCalled
	if 0<(time.time() - _lastCalled)<=3:
		_lastCalled = time.time()
		return 1
	else:
		_lastCalled = time.time()
		return 0

It essentially does the same thing but with a delay of 3 seconds. Why wasn't the delay less than 0.5 seconds? That's still a mystery.

Speaking of mysteries, the image captioning add-on would crash with errors if a recognition process is started before the previous one has completed. In the end, we narrowed it down to the use of a global variable in the DLL that might've been causing the problem. I'm still not sure if that was the cause since I felt it was just easier to prevent a new recognition process from starting. This saved me quite a bit of time. I must get the add-ons out for feedback, as often as possible, because I have little time left.

I also made a little manual testing checklist that can be found here.

Thankfully, the feedback has been a little more positive this time around, but there is still some work to do. For starters, it seems like there are some more ways of navigating webpages with NVDA that I am still not aware of. This makes it a little more difficult for me to recreate the issues and fix them. Thankfully, that is a small hill for me to climb. I also need to make a few changes with the settings and remove the enable checkbox for each add-on.

I am glad that I have managed to check off almost all the plans I had in mind for these add-ons as I near the end of this internship. I still need to make minor changes/fixes and write the reports. What I am most excited for is contributing to the source code the changes I believe will prove to be beneficial to everyone and also creating a few issues I discovered here and there. After all, that is what open-source is all about!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment