OSDN Git Service

If the input language is changed to something other than the default, NVDA now detect...
authorJames Teh <jamie@jantrid.net>
Tue, 8 Jan 2013 08:43:59 +0000 (18:43 +1000)
committerJames Teh <jamie@jantrid.net>
Tue, 8 Jan 2013 08:43:59 +0000 (18:43 +1000)
When the input language is changed, it only happens for the input (focused) thread, so NVDA's hook thread is still using a different keyboard layout and MapVirtualKey/VkKeyScan use that. To fix this, we use MapVirtualKeyEx/VkKeyScanEx and pass the hkl of the input thread.

source/keyboardHandler.py
source/winUser.py
user_docs/en/changes.t2t

index f05bda1..67fadee 100644 (file)
@@ -201,6 +201,17 @@ def initialize():
 def terminate():\r
        winInputHook.terminate()\r
 \r
+def getInputHkl():\r
+       """Obtain the hkl currently being used for input.\r
+       This retrieves the hkl from the thread of the focused window.\r
+       """\r
+       focus = api.getFocusObject()\r
+       if focus:\r
+               thread = focus.windowThreadID\r
+       else:\r
+               thread = 0\r
+       return winUser.user32.GetKeyboardLayout(thread)\r
+\r
 class KeyboardInputGesture(inputCore.InputGesture):\r
        """A key pressed on the traditional system keyboard.\r
        """\r
@@ -272,7 +283,7 @@ class KeyboardInputGesture(inputCore.InputGesture):
 \r
                if 32 < self.vkCode < 128:\r
                        return unichr(self.vkCode).lower()\r
-               vkChar = winUser.user32.MapVirtualKeyW(self.vkCode, winUser.MAPVK_VK_TO_CHAR)\r
+               vkChar = winUser.user32.MapVirtualKeyExW(self.vkCode, winUser.MAPVK_VK_TO_CHAR, getInputHkl())\r
                if vkChar>0:\r
                        return unichr(vkChar).lower()\r
 \r
@@ -390,7 +401,7 @@ class KeyboardInputGesture(inputCore.InputGesture):
                                ext = False\r
                        elif len(keyName) == 1:\r
                                ext = False\r
-                               requiredMods, vk = winUser.VkKeyScan(keyName)\r
+                               requiredMods, vk = winUser.VkKeyScanEx(keyName, getInputHkl())\r
                                if requiredMods & 1:\r
                                        keys.append((winUser.VK_SHIFT, False))\r
                                if requiredMods & 2:\r
index a82561d..2aebbf5 100644 (file)
@@ -491,9 +491,9 @@ def PostMessage(hwnd, msg, wParam, lParam):
        if not user32.PostMessageW(hwnd, msg, wParam, lParam):\r
                raise WinError()\r
 \r
-user32.VkKeyScanW.restype = SHORT\r
-def VkKeyScan(ch):\r
-       res = user32.VkKeyScanW(WCHAR(ch))\r
+user32.VkKeyScanExW.restype = SHORT\r
+def VkKeyScanEx(ch, hkl):\r
+       res = user32.VkKeyScanW(WCHAR(ch), hkl)\r
        if res == -1:\r
                raise LookupError\r
        return res >> 8, res & 0xFF\r
index 6539985..f2101fd 100644 (file)
@@ -30,6 +30,7 @@
 - When disabling automatic checking for updates, NVDA no longer has to be restarted in order for the change to fully take effect.\r
 - NVDA no longer fails to start if an add-on cannot be removed due to its directory currently being in use by another application. (#2860)\r
 - Tab labels in DropBox's preferences dialog can now be seen with Flat Review.\r
+- If the input language is changed to something other than the default, NVDA now detects keys correctly for commands and input help mode.\r
 \r
 \r
 == Changes for Developers ==\r