Changeset 2429
- Timestamp:
- 10/12/08 08:55:18 (6 weeks ago)
- Location:
- trunk/source
- Files:
-
- 3 modified
-
keyUtils.py (modified) (1 diff)
-
keyboardHandler.py (modified) (5 diffs)
-
winUser.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/keyUtils.py
r2177 r2429 107 107 time.sleep(0.01) 108 108 wx.Yield() 109 110 localizedKeyLabels={ 111 'back': _("backspace"), 112 'capital': _("caps lock"), 113 'control': _("ctrl"), 114 'alt': _("alt"), 115 'shift': _("shift"), 116 'win': _("windows"), 117 'return': _("enter"), 118 'extendedreturn': _("numpad enter"), 119 'escape': _("escape"), 120 'space': _("space"), 121 'extendedprior': _("page up"), 122 'extendednext': _("page down"), 123 'extendedend': _("end"), 124 'extendedhome': _("home"), 125 'extendeddelete': _("delete"), 126 'extendedleft': _("left arrow"), 127 'extendedright': _("right arrow"), 128 'extendedup': _("up arrow"), 129 'extendeddown': _("down arrow"), 130 'extendedapps': _("applications"), 131 'extendednumlock': _("num lock"), 132 'extendedsnapshot': _("snapshot"), 133 'scroll': _("scrol lock"), 134 'left': _("numpad left"), 135 'right': _("numpad right"), 136 'up': _("numpad up"), 137 'down': _("numpad down"), 138 'prior': _("numpad page up"), 139 'next': _("numpad page down"), 140 'end': _("numpad end"), 141 'home': _("numpad home"), 142 'extendeddivide': _("numpad slash"), 143 'multiply': _("numpad star"), 144 'subtract': _("numpad minus"), 145 'add': _("numpad plus"), 146 'lcontrol': _("left control"), 147 'extendedrcontrol': _("right control"), 148 'extendedlwin': _("left windows"), 149 'lshift': _("left shift"), 150 'extendedrshift': _("right shift"), 151 'lmenu': _("left alt"), 152 'extendedrmenu': _("right alt"), 153 'extendedrwin': _("right windows") 154 } -
trunk/source/keyboardHandler.py
r2272 r2429 13 13 import vkCodes 14 14 import speech 15 from keyUtils import key, keyName, sendKey 15 from keyUtils import key, keyName, sendKey, localizedKeyLabels 16 16 import scriptHandler 17 17 import globalVars … … 78 78 @ctypes.CFUNCTYPE(ctypes.c_int,ctypes.c_int,ctypes.c_int,ctypes.c_int,ctypes.c_int) 79 79 def internal_keyDownEvent(vkCode,scanCode,extended,injected): 80 """Event called by pyHook when it receives a keyDown. It sees if there is a script tied to this key and if so executes it. It also handles the speaking of characters, words and command keys.80 """Event called by keyHook when it receives a keyDown. It sees if there is a script tied to this key and if so executes it. It also handles the speaking of characters, words and command keys. 81 81 """ 82 82 try: … … 112 112 if isNVDAModifierKey(vkCode,extended): 113 113 NVDAModifierKey=(vkCode,extended) 114 return False 115 if vkCode in [winUser.VK_CONTROL,winUser.VK_LCONTROL,winUser.VK_RCONTROL,winUser.VK_SHIFT,winUser.VK_LSHIFT,winUser.VK_RSHIFT,winUser.VK_MENU,winUser.VK_LMENU,winUser.VK_RMENU,winUser.VK_LWIN,winUser.VK_RWIN]: 114 if not globalVars.keyboardHelp: 115 return False 116 if not globalVars.keyboardHelp and vkCode in [winUser.VK_CONTROL,winUser.VK_LCONTROL,winUser.VK_RCONTROL,winUser.VK_SHIFT,winUser.VK_LSHIFT,winUser.VK_RSHIFT,winUser.VK_MENU,winUser.VK_LMENU,winUser.VK_RMENU,winUser.VK_LWIN,winUser.VK_RWIN]: 116 117 return True 117 118 modifierList=[] 118 119 if NVDAModifierKey: 119 120 modifierList.append("nvda") 120 if winUser.getKeyState(winUser.VK_CONTROL)&32768:121 if not vkCode in [winUser.VK_CONTROL,winUser.VK_LCONTROL,winUser.VK_RCONTROL] and winUser.getKeyState(winUser.VK_CONTROL)&32768: 121 122 modifierList.append("control") 122 if winUser.getKeyState(winUser.VK_SHIFT)&32768:123 if not vkCode in [winUser.VK_SHIFT,winUser.VK_LSHIFT,winUser.VK_RSHIFT] and winUser.getKeyState(winUser.VK_SHIFT)&32768: 123 124 modifierList.append("shift") 124 if winUser.getKeyState(winUser.VK_MENU)&32768:125 if not vkCode in [winUser.VK_MENU,winUser.VK_LMENU,winUser.VK_RMENU] and winUser.getKeyState(winUser.VK_MENU)&32768: 125 126 modifierList.append("alt") 126 if winUser.getKeyState(winUser.VK_LWIN)&32768:127 if not vkCode in [winUser.VK_LWIN,winUser.VK_RWIN] and winUser.getKeyState(winUser.VK_LWIN)&32768: 127 128 modifierList.append("win") 128 if winUser.getKeyState(winUser.VK_RWIN)&32768:129 if not vkCode in [winUser.VK_LWIN,winUser.VK_RWIN] and winUser.getKeyState(winUser.VK_RWIN)&32768: 129 130 modifierList.append("win") 130 131 if len(modifierList) > 0: … … 133 134 modifiers=None 134 135 mainKey=vkName 136 if not mainKey: 137 mainKey=winUser.getKeyNameText(scanCode,extended) 135 138 if extended==1: 136 139 mainKey="extended%s"%mainKey … … 138 141 if log.isEnabledFor(log.IO): log.io("key press: %s"%keyName(keyPress)) 139 142 if globalVars.keyboardHelp or (config.conf["keyboard"]["speakCommandKeys"] and not ( not keyPress[0] and config.conf["keyboard"]["speakTypedCharacters"])): 140 labelList=[] 141 if keyPress[0] is not None: 142 labelList.extend(keyPress[0]) 143 ch=ctypes.windll.user32.MapVirtualKeyW(vkCode,winUser.MAPVK_VK_TO_CHAR) 144 if ch>32: 145 labelList.append(unichr(ch)) 146 else: 147 labelList.append(keyPress[1]) 143 labelList = [] 144 if modifiers: 145 for mod in modifiers: 146 if localizedKeyLabels.has_key(mod): 147 labelList.append(localizedKeyLabels[mod]) 148 else: 149 labelList.append(mod) 150 if not isNVDAModifierKey(vkCode,extended): 151 ch=ctypes.windll.user32.MapVirtualKeyW(vkCode,winUser.MAPVK_VK_TO_CHAR) 152 if localizedKeyLabels.has_key(keyPress[1]): 153 labelList.append(localizedKeyLabels[keyPress[1]]) 154 elif ch>=32 and not mainKey.startswith('numpad') and not mainKey in ('extendeddivide', 'multiply', 'subtract', 'add', 'extendedreturn', 'decimal'): 155 labelList.append(unichr(ch)) 156 else: 157 labelList.append(keyPress[1]) 148 158 queueHandler.queueFunction(queueHandler.eventQueue,speech.speakMessage,"+".join(labelList)) 149 if (mainKey in ('extendeddivide', 'multiply', 'subtract', 'add', 'extendedreturn')) and (bool(winUser.getKeyState(winUser.VK_NUMLOCK)&1)):159 if not globalVars.keyboardHelp and (mainKey in ('extendeddivide', 'multiply', 'subtract', 'add', 'extendedreturn')) and (bool(winUser.getKeyState(winUser.VK_NUMLOCK)&1)): 150 160 return True 151 161 script=scriptHandler.findScript(keyPress) 152 162 if script: 153 163 scriptName=scriptHandler.getScriptName(script) 154 scriptLocation=scriptHandler.getScriptLocation(script)155 scriptDescription=scriptHandler.getScriptDescription(script)156 164 if globalVars.keyboardHelp and scriptName!="keyboardHelp": 157 queueHandler.queueFunction(queueHandler.eventQueue,speech.speakMessage,"%s"%scriptName.replace('_',' '))158 queueHandler.queueFunction(queueHandler.eventQueue,speech.speakMessage,_("Description: %s")%scriptDescription)159 queueHandler.queueFunction(queueHandler.eventQueue,speech.speakMessage,_("Location: %s")%script Location)165 scriptDescription = scriptHandler.getScriptDescription(script) 166 if scriptDescription: queueHandler.queueFunction(queueHandler.eventQueue,speech.speakMessage,_("Description: %s")%scriptDescription) 167 queueHandler.queueFunction(queueHandler.eventQueue,speech.speakMessage,_("Location: %s")%scriptHandler.getScriptLocation(script)) 160 168 else: 161 169 scriptHandler.queueScript(script,keyPress) -
trunk/source/winUser.py
r2177 r2429 74 74 WM_GETTEXT=13 75 75 WM_GETTEXTLENGTH=14 76 WM_PAINT=0x000F 76 77 #Clipboard formats 77 78 CF_TEXT=1 … … 377 378 def getKeyboardLayout(idThread=0): 378 379 return user32.GetKeyboardLayout(idThread) 380 381 def updateWindow(hwnd): 382 return user32.UpdateWindow(hwnd) 383 384 def invalidateRect(hwnd): 385 return user32.InvalidateRect(hwnd,None,False) 386 387 def getKeyNameText(scanCode,extended): 388 buf=create_unicode_buffer(32) 389 user32.GetKeyNameTextW((scanCode<<16)|(extended<<24),buf,31) 390 return buf.value

NVDA is supported by