Skip to content

Commit 0ec6e0c

Browse files
authored
Merge 7fd2e68 into fba44b4
2 parents fba44b4 + 7fd2e68 commit 0ec6e0c

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

source/JABHandler.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
import core
4040
import textUtils
4141
import 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+
741766
def 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):

0 commit comments

Comments
 (0)