1- # -*- coding: UTF-8 -*-
1+ # -*- coding: UTF-8 -*-
22# A part of NonVisual Desktop Access (NVDA)
33# Copyright (C) 2007-2023 NV Access Limited, Peter Vágner, Renaud Paquay, Babbage B.V.
44# This file is covered by the GNU General Public License.
77from enum import IntEnum , IntFlag
88import os
99import queue
10+ from sys import maxsize
1011from ctypes import (
1112 c_short ,
1213 c_long ,
4344import config
4445from 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.
4852A11Y_PROPS_PATH = os .path .expanduser (r"~\.accessibility.properties" )
5357)
5458
5559#Some utility functions to help with function defines
56-
5760def _errcheck (res , func , args ):
5861 if not res :
5962 raise RuntimeError ("Result %s" % res )
@@ -80,8 +83,8 @@ def _fixBridgeFunc(restype,name,*argtypes,**kwargs):
8083jfloat = c_float
8184jboolean = c_bool
8285
83-
84- class JOBJECT64 (c_int64 ):
86+ # If the machine is 64-bit, use c_int64, otherwise use c_int as a parameter.
87+ class JOBJECT64 (c_int64 if is_64Bit else c_int ):
8588 pass
8689AccessibleTable = JOBJECT64
8790
@@ -791,7 +794,7 @@ def event_enterJavaWindow(hwnd):
791794def enterJavaWindow_helper (hwnd ):
792795 vmID = c_long ()
793796 accContext = JOBJECT64 ()
794- timeout = time .time ()+ 0.2
797+ timeout = time .time ()+ 0.5
795798 while time .time ()< timeout and not eventHandler .isPendingEvents ("gainFocus" ):
796799 try :
797800 bridgeDll .getAccessibleContextWithFocus (hwnd ,byref (vmID ),byref (accContext ))
@@ -836,10 +839,12 @@ def enableBridge():
836839
837840
838841def initialize ():
839- global bridgeDll , isRunning
842+ global bridgeDll , is_64Bit , isRunning
843+ # If the system is 64-bit, load the dll that we have in the NVDA distribution.
844+ # Otherwise, it loads the one on the 32-bit system, which does not have the -32 suffix.
845+ correctDll = os .path .join (NVDAHelper .versionedLibPath , "windowsaccessbridge-32.dll" ) if is_64Bit else "windowsaccessbridge.dll"
840846 try :
841- bridgeDll = cdll .LoadLibrary (
842- os .path .join (NVDAHelper .versionedLibPath , "windowsaccessbridge-32.dll" ))
847+ bridgeDll = cdll .LoadLibrary (correctDll )
843848 except WindowsError :
844849 raise NotImplementedError ("dll not available" )
845850 _fixBridgeFuncs ()
0 commit comments