New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speak typed characters in UWP apps on Windows 10 RS2 and above #6631
Conversation
for apps in Win 10 rs1 and above where we cannot inject in-process.
…ws.ui.Core windows from 14946 onwards.
…indows build 14986 and up.
@@ -162,6 +167,21 @@ def internal_keyDownEvent(vkCode,scanCode,extended,injected): | |||
return False | |||
except: | |||
log.error("internal_keyDownEvent", exc_info=True) | |||
finally: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth commenting why we do this in the finally block; i.e. because we return early in several places but we still want this to be executed.
finally: | ||
# #6017: handle typed characters for UWP apps in Win10 RS2 and above where we can't detect typed characters in-process | ||
focus=api.getFocusObject() | ||
if sys.getwindowsversion().build>=14986 and not gestureExecuted and not isNVDAModifierKey(vkCode,extended) and not vkCode in KeyboardInputGesture.NORMAL_MODIFIER_KEYS and focus.windowClassName.startswith('Windows.UI.Core'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling sys.getwindowsversion
probably isn't expensive, but we already have it cached in winVersion.winVersion
anyway, so I'd use that instead.
keyStates[k]=ctypes.windll.user32.GetKeyState(k) | ||
charBuf=ctypes.create_unicode_buffer(5) | ||
# Normally calling ToUnicodeEx would destroy keyboard buffer state and therefore cause the app to not produce the right WM_CHAR message. | ||
# However in UWP apps in Windows 10 RS2 and above, wm_keydown / wm_char is never processed, thus NVDA will be the only one calling it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still true? I thought the point of the flag was to stop this state destroying behaviour, rather than it being something specific to UWP.
# Normally calling ToUnicodeEx would destroy keyboard buffer state and therefore cause the app to not produce the right WM_CHAR message. | ||
# However in UWP apps in Windows 10 RS2 and above, wm_keydown / wm_char is never processed, thus NVDA will be the only one calling it. | ||
hkl=ctypes.windll.user32.GetKeyboardLayout(focus.windowThreadID) | ||
res=ctypes.windll.user32.ToUnicodeEx(vkCode,scanCode,keyStates,charBuf,5,4,hkl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I assume
4
is the flag? Please comment as to what the4
does. - I assume
5
is the size? Perhaps uselen(charBuf)
to be clearer and so we don't break things if we change the size in future.
res=ctypes.windll.user32.ToUnicodeEx(vkCode,scanCode,keyStates,charBuf,5,4,hkl) | ||
if res>0: | ||
for ch in charBuf[:res]: | ||
eventHandler.queueEvent("typedCharacter",focus,ch=ch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this saying there can be multiple separate characters? I know there are languages where a single key press produces a conjunct Unicode character sequence (e.g. Tamil), but we probably actually want that to be handled as one character. We can't do that with WM_CHAR right now, but is there a reason we shouldn't do this here since we can?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have certainly seen it produce at least 2 characters yes. For instance, if a dead key is hit, followed by a character that is not compatible with a dead key, then you get a char for the dead key (say ^) and also the actual character.
Actually, technically the flag is only needed for non-uwp apps as TranslateMessage is never called. So technically, we could just call it with a flag of 0 and that comment would be correct. However, if we were to ever extend the use of this code to outside of UWP apps, then the flag is most certainly needed. The actual mS bug I filed was to ensure that the flag produced the same results whether it was UWP or not. As in older Windows builds, the flag in UWP apps breaks things just as badly as if ToUnicodeEx were used in conjunction with TranslateMessage, and no flag given. |
When will this fix in nvda next? and will be in the release 2017.1 |
It only will work for insider builds until rs2.
Also @michaelDCurran I'd recommend this incubate in next for longer than
usual since it won't be tested until RS2.
…On 12/24/2016 12:06 PM, nikita wrote:
When will this fix in nvda next? and will be in the release 2017.1
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6631 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFGivUu8sHfY0OVlffat6EYk9kd9xwKqks5rLW1NgaJpZM4LHgGc>.
--
------------------------------------------------------------------------
Derek Riemer
* Department of computer science, third year undergraduate student.
* Proud user of the NVDA screen reader.
* Open source enthusiast.
* Member of Bridge Cu
* Avid skiier.
Websites:
Honors portfolio <http://derekriemer.com>
Awesome little hand built weather app!
<http://django.derekriemer.com/weather/>
email me at derek.riemer@colorado.edu <mailto:derek.riemer@colorado.edu>
Phone: (303) 906-2194
|
Hi, RS2 is under development, so I do second Derek’s proposal that this get incubated for a long time (at least three weeks, I’d say). Thanks.
From: derekriemer [mailto:notifications@github.com]
Sent: Saturday, December 24, 2016 7:10 PM
To: nvaccess/nvda <nvda@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: Re: [nvaccess/nvda] Speak typed characters in UWP apps on Windows 10 RS2 and above (#6631)
It only will work for insider builds until rs2.
Also @michaelDCurran I'd recommend this incubate in next for longer than
usual since it won't be tested until RS2.
…On 12/24/2016 12:06 PM, nikita wrote:
When will this fix in nvda next? and will be in the release 2017.1
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6631 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFGivUu8sHfY0OVlffat6EYk9kd9xwKqks5rLW1NgaJpZM4LHgGc>.
--
------------------------------------------------------------------------
Derek Riemer
* Department of computer science, third year undergraduate student.
* Proud user of the NVDA screen reader.
* Open source enthusiast.
* Member of Bridge Cu
* Avid skiier.
Websites:
Honors portfolio <http://derekriemer.com>
Awesome little hand built weather app!
<http://django.derekriemer.com/weather/>
email me at derek.riemer@colorado.edu <mailto:derek.riemer@colorado.edu>
Phone: (303) 906-2194
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#6631 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AHgLkAUFLJRN0g6x8BLZxW_FWlLCweEMks5rLd6OgaJpZM4LHgGc> .
|
@jcsteh: I have made all requested changes. |
Hi, Critical bug found: After installing next.13789, try typing into Start menu or UWP apps. At least in build 14986 (my laptop), I get a traceback that says: ERROR - unhandled exception (19:55:28): Same result when I try to type an address into Edge. This was with speak typed chars set to off. Thanks. |
Oops. My mistake.
That function is missing an argument.
|
Hi, Try the following:
Expected: no errors. |
Hi, Try the following:
Expected: no errors. ERROR - eventHandler.executeEvent (15:47:46): This happens on next.13789 and later, thus I suspect this has to do with this pull request. Thanks. |
@josephsl I'd say that if speak typed characters had originally worked in UWP apps without this code, we'd see the same errors here. As they don't impact on usage, I won't hold back this PR. However we may consider cleaning up the way errors in api.isprotected are handled, as this does seem to happen quite a bit. |
Fixes #6017
This code will only work on Windows build 14986 and above.