File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939import core
4040import textUtils
4141import NVDAHelper
42+ import config
43+
44+ #: The path to the user's .accessibility.properties file, used
45+ #: to enable JAB.
46+ A11Y_PROPS_PATH = os .path .expanduser (r"~\.accessibility.properties" )
47+ #: The content of ".accessibility.properties" when JAB is enabled.
48+ A11Y_PROPS_CONTENT = (
49+ "assistive_technologies=com.sun.java.accessibility.AccessBridge\n "
50+ "screen_magnifier_present=true\n "
51+ )
4252
4353#Some utility functions to help with function defines
4454
@@ -738,6 +748,21 @@ def isJavaWindow(hwnd):
738748 return False
739749 return bridgeDll .isJavaWindow (hwnd )
740750
751+ def isBridgeEnabled ():
752+ try :
753+ data = open (A11Y_PROPS_PATH , "rt" ).read ()
754+ except OSError :
755+ return False
756+ return data == A11Y_PROPS_CONTENT
757+
758+ def enableBridge ():
759+ try :
760+ props = open (A11Y_PROPS_PATH , "wt" )
761+ props .write (A11Y_PROPS_CONTENT )
762+ log .info ("Enabled Java Access Bridge for user" )
763+ except OSError :
764+ log .warning ("Couldn't enable Java Access Bridge for user" , exc_info = True )
765+
741766def initialize ():
742767 global bridgeDll , isRunning
743768 try :
@@ -746,6 +771,8 @@ def initialize():
746771 except WindowsError :
747772 raise NotImplementedError ("dll not available" )
748773 _fixBridgeFuncs ()
774+ if config .isInstalledCopy () and not isBridgeEnabled ():
775+ enableBridge ()
749776 bridgeDll .Windows_run ()
750777 # Accept wm_copydata and any wm_user messages from other processes even if running with higher privileges
751778 if not windll .user32 .ChangeWindowMessageFilter (winUser .WM_COPYDATA , 1 ):
You can’t perform that action at this time.
0 commit comments