Skip to content

Commit 833372a

Browse files
Merge 2a64785 into fdc3e9e
2 parents fdc3e9e + 2a64785 commit 833372a

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

source/JABHandler.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from enum import IntEnum, IntFlag
88
import os
99
import queue
10+
from sys import maxsize
1011
from ctypes import (
1112
c_short,
1213
c_long,
@@ -43,6 +44,9 @@
4344
import config
4445
from utils.security import isRunningOnSecureDesktop
4546

47+
#: Verification of the architecture of the running system
48+
is_64Bit = maxsize > 2**32
49+
4650
#: The path to the user's .accessibility.properties file, used
4751
#: to enable JAB.
4852
A11Y_PROPS_PATH = os.path.expanduser(r"~\.accessibility.properties")
@@ -53,7 +57,6 @@
5357
)
5458

5559
#Some utility functions to help with function defines
56-
5760
def _errcheck(res, func, args):
5861
if not res:
5962
raise RuntimeError("Result %s" % res)
@@ -81,7 +84,8 @@ def _fixBridgeFunc(restype,name,*argtypes,**kwargs):
8184
jboolean=c_bool
8285

8386

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):
8589
pass
8690
AccessibleTable=JOBJECT64
8791

@@ -791,7 +795,7 @@ def event_enterJavaWindow(hwnd):
791795
def enterJavaWindow_helper(hwnd):
792796
vmID=c_long()
793797
accContext=JOBJECT64()
794-
timeout=time.time()+0.2
798+
timeout=time.time() + 0.5
795799
while time.time()<timeout and not eventHandler.isPendingEvents("gainFocus"):
796800
try:
797801
bridgeDll.getAccessibleContextWithFocus(hwnd,byref(vmID),byref(accContext))
@@ -836,10 +840,15 @@ def enableBridge():
836840

837841

838842
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"
840850
try:
841-
bridgeDll = cdll.LoadLibrary(
842-
os.path.join(NVDAHelper.versionedLibPath, "windowsaccessbridge-32.dll"))
851+
bridgeDll = cdll.LoadLibrary(correctDll)
843852
except WindowsError:
844853
raise NotImplementedError("dll not available")
845854
_fixBridgeFuncs()

0 commit comments

Comments
 (0)