44# This file is covered by the GNU General Public License.
55# See the file COPYING for more details.
66
7+ import os
78import queue
89from ctypes import (
910 c_short ,
3738import NVDAObjects .JAB
3839import core
3940import textUtils
41+ import NVDAHelper
4042
4143#Some utility functions to help with function defines
4244
@@ -56,24 +58,15 @@ def _fixBridgeFunc(restype,name,*argtypes,**kwargs):
5658 if kwargs .get ('errcheck' ):
5759 func .errcheck = _errcheck
5860
59- #Load the first available access bridge dll
60- legacyAccessBridge = True
61- try :
62- bridgeDll = getattr (cdll ,'windowsAccessBridge-32' )
63- legacyAccessBridge = False
64- except WindowsError :
65- try :
66- bridgeDll = cdll .windowsAccessBridge
67- except WindowsError :
68- bridgeDll = None
61+ bridgeDll = None
6962
7063#Definitions of access bridge types, structs and prototypes
7164
7265jchar = c_wchar
7366jint = c_int
7467jfloat = c_float
7568jboolean = c_bool
76- class JOBJECT64 (c_int if legacyAccessBridge else c_int64 ):
69+ class JOBJECT64 (c_int64 ):
7770 pass
7871AccessibleTable = JOBJECT64
7972
@@ -248,8 +241,9 @@ class AccessibleKeyBindings(Structure):
248241AccessBridge_PropertyCaretChangeFP = CFUNCTYPE (None ,c_long ,JOBJECT64 ,JOBJECT64 ,c_int ,c_int )
249242AccessBridge_PropertyActiveDescendentChangeFP = CFUNCTYPE (None ,c_long ,JOBJECT64 ,JOBJECT64 ,JOBJECT64 ,JOBJECT64 )
250243
251- #Appropriately set the return and argument types of all the access bridge dll functions
252- if bridgeDll :
244+ def _fixBridgeFuncs ():
245+ """Appropriately set the return and argument types of all the access bridge dll functions
246+ """
253247 _fixBridgeFunc (None ,'Windows_run' )
254248 _fixBridgeFunc (None ,'setFocusGainedFP' ,c_void_p )
255249 _fixBridgeFunc (None ,'setPropertyNameChangeFP' ,c_void_p )
@@ -741,9 +735,13 @@ def isJavaWindow(hwnd):
741735 return bridgeDll .isJavaWindow (hwnd )
742736
743737def initialize ():
744- global isRunning
745- if not bridgeDll :
738+ global bridgeDll , isRunning
739+ try :
740+ bridgeDll = cdll .LoadLibrary (
741+ os .path .join (NVDAHelper .versionedLibPath , "windowsaccessbridge-32.dll" ))
742+ except WindowsError :
746743 raise NotImplementedError ("dll not available" )
744+ _fixBridgeFuncs ()
747745 bridgeDll .Windows_run ()
748746 # Accept wm_copydata and any wm_user messages from other processes even if running with higher privileges
749747 if not windll .user32 .ChangeWindowMessageFilter (winUser .WM_COPYDATA , 1 ):
@@ -775,9 +773,5 @@ def terminate():
775773 bridgeDll .setPropertyCaretChangeFP (None )
776774 h = bridgeDll ._handle
777775 bridgeDll = None
778- if legacyAccessBridge :
779- del cdll .windowsAccessBridge
780- else :
781- delattr (cdll ,'windowsAccessBridge-32' )
782776 windll .kernel32 .FreeLibrary (h )
783777 isRunning = False
0 commit comments