Skip to content

Commit

Permalink
Merge 2a64785 into fdc3e9e
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeZanabria committed May 16, 2024
2 parents fdc3e9e + 2a64785 commit 833372a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions source/JABHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from enum import IntEnum, IntFlag
import os
import queue
from sys import maxsize
from ctypes import (
c_short,
c_long,
Expand Down Expand Up @@ -43,6 +44,9 @@
import config
from utils.security import isRunningOnSecureDesktop

#: Verification of the architecture of the running system
is_64Bit = maxsize > 2**32

#: The path to the user's .accessibility.properties file, used
#: to enable JAB.
A11Y_PROPS_PATH = os.path.expanduser(r"~\.accessibility.properties")
Expand All @@ -53,7 +57,6 @@
)

#Some utility functions to help with function defines

def _errcheck(res, func, args):
if not res:
raise RuntimeError("Result %s" % res)
Expand Down Expand Up @@ -81,7 +84,8 @@ def _fixBridgeFunc(restype,name,*argtypes,**kwargs):
jboolean=c_bool


class JOBJECT64(c_int64):
# If the machine is 64-bit, use c_int64, otherwise use c_int as a parameter.
class JOBJECT64(c_int64 if is_64Bit else c_int):
pass
AccessibleTable=JOBJECT64

Expand Down Expand Up @@ -791,7 +795,7 @@ def event_enterJavaWindow(hwnd):
def enterJavaWindow_helper(hwnd):
vmID=c_long()
accContext=JOBJECT64()
timeout=time.time()+0.2
timeout=time.time() + 0.5
while time.time()<timeout and not eventHandler.isPendingEvents("gainFocus"):
try:
bridgeDll.getAccessibleContextWithFocus(hwnd,byref(vmID),byref(accContext))
Expand Down Expand Up @@ -836,10 +840,15 @@ def enableBridge():


def initialize():
global bridgeDll, isRunning
global bridgeDll, is_64Bit, isRunning
# If the system is 64-bit, load the dll that we have in the NVDA distribution.
# Otherwise, it loads the one on the 32-bit system, which does not have the -32 suffix.
if is_64Bit:
correctDll = os.path.join(NVDAHelper.versionedLibPath, "windowsaccessbridge-32.dll")
else:
correctDll = "windowsaccessbridge.dll"
try:
bridgeDll = cdll.LoadLibrary(
os.path.join(NVDAHelper.versionedLibPath, "windowsaccessbridge-32.dll"))
bridgeDll = cdll.LoadLibrary(correctDll)
except WindowsError:
raise NotImplementedError("dll not available")
_fixBridgeFuncs()
Expand Down

0 comments on commit 833372a

Please sign in to comment.