|
7 | 7 | from enum import IntEnum, IntFlag |
8 | 8 | import os |
9 | 9 | import queue |
| 10 | +from sys import maxsize |
10 | 11 | from ctypes import ( |
11 | 12 | c_short, |
12 | 13 | c_long, |
|
43 | 44 | import config |
44 | 45 | from utils.security import isRunningOnSecureDesktop |
45 | 46 |
|
| 47 | +#: Verification of the architecture of the running system |
| 48 | +is_64Bit = maxsize > 2**32 |
| 49 | + |
46 | 50 | #: The path to the user's .accessibility.properties file, used |
47 | 51 | #: to enable JAB. |
48 | 52 | A11Y_PROPS_PATH = os.path.expanduser(r"~\.accessibility.properties") |
|
53 | 57 | ) |
54 | 58 |
|
55 | 59 | #Some utility functions to help with function defines |
56 | | - |
57 | 60 | def _errcheck(res, func, args): |
58 | 61 | if not res: |
59 | 62 | raise RuntimeError("Result %s" % res) |
@@ -81,7 +84,8 @@ def _fixBridgeFunc(restype,name,*argtypes,**kwargs): |
81 | 84 | jboolean=c_bool |
82 | 85 |
|
83 | 86 |
|
84 | | -class JOBJECT64(c_int64): |
| 87 | +# If the machine is 64-bit, use c_int64, otherwise use c_int as a parameter. |
| 88 | +class JOBJECT64(c_int64 if is_64Bit else c_int): |
85 | 89 | pass |
86 | 90 | AccessibleTable=JOBJECT64 |
87 | 91 |
|
@@ -791,7 +795,7 @@ def event_enterJavaWindow(hwnd): |
791 | 795 | def enterJavaWindow_helper(hwnd): |
792 | 796 | vmID=c_long() |
793 | 797 | accContext=JOBJECT64() |
794 | | - timeout=time.time()+0.2 |
| 798 | + timeout=time.time() + 0.5 |
795 | 799 | while time.time()<timeout and not eventHandler.isPendingEvents("gainFocus"): |
796 | 800 | try: |
797 | 801 | bridgeDll.getAccessibleContextWithFocus(hwnd,byref(vmID),byref(accContext)) |
@@ -836,10 +840,15 @@ def enableBridge(): |
836 | 840 |
|
837 | 841 |
|
838 | 842 | def initialize(): |
839 | | - global bridgeDll, isRunning |
| 843 | + global bridgeDll, is_64Bit, isRunning |
| 844 | + # If the system is 64-bit, load the dll that we have in the NVDA distribution. |
| 845 | + # Otherwise, it loads the one on the 32-bit system, which does not have the -32 suffix. |
| 846 | + if is_64Bit: |
| 847 | + correctDll = os.path.join(NVDAHelper.versionedLibPath, "windowsaccessbridge-32.dll") |
| 848 | + else: |
| 849 | + correctDll = "windowsaccessbridge.dll" |
840 | 850 | try: |
841 | | - bridgeDll = cdll.LoadLibrary( |
842 | | - os.path.join(NVDAHelper.versionedLibPath, "windowsaccessbridge-32.dll")) |
| 851 | + bridgeDll = cdll.LoadLibrary(correctDll) |
843 | 852 | except WindowsError: |
844 | 853 | raise NotImplementedError("dll not available") |
845 | 854 | _fixBridgeFuncs() |
|
0 commit comments