def initialize():
	for eventType in winEventIDsToNVDAEventNames.keys():
		hookID=winUser.setWinEventHook(eventType,eventType,0,cWinEventCallback,0,0,0)
		if hookID:
			winEventHookIDs.append(hookID)
		else:
			log.error("initialize: could not register callback for event %s (%s)"%(eventType,winEventIDsToNVDAEventNames[eventType]))
def connectConsole(obj):
    global consoleObject, consoleOutputHandle, checkDeadTimer
    #Get the process ID of the console this NVDAObject is fore
    processID, threadID = winUser.getWindowThreadProcessID(obj.windowHandle)
    #Attach NVDA to this console so we can access its text etc
    try:
        wincon.AttachConsole(processID)
    except WindowsError as e:
        log.debugWarning("Could not attach console: %r" % e)
        return False
    wincon.SetConsoleCtrlHandler(_consoleCtrlHandler, True)
    consoleOutputHandle = winKernel.CreateFile(
        u"CONOUT$", winKernel.GENERIC_READ | winKernel.GENERIC_WRITE,
        winKernel.FILE_SHARE_READ | winKernel.FILE_SHARE_WRITE, None,
        winKernel.OPEN_EXISTING, 0, None)
    #Register this callback with all the win events we need, storing the given handles for removal later
    for eventID in (winUser.EVENT_CONSOLE_CARET,
                    winUser.EVENT_CONSOLE_UPDATE_REGION,
                    winUser.EVENT_CONSOLE_UPDATE_SIMPLE,
                    winUser.EVENT_CONSOLE_UPDATE_SCROLL,
                    winUser.EVENT_CONSOLE_LAYOUT):
        handle = winUser.setWinEventHook(eventID, eventID, 0,
                                         consoleWinEventHook, 0, 0, 0)
        if not handle:
            raise OSError("could not register eventID %s" % eventID)
        consoleWinEventHookHandles.append(handle)
    consoleObject = obj
    checkDeadTimer = gui.NonReEntrantTimer(_checkDead)
    checkDeadTimer.Start(CHECK_DEAD_INTERVAL)
    return True
Esempio n. 3
0
def initialize():
	global _remoteLib, _remoteLoader64, localLib, winEventHookID,generateBeep,VBuf_getTextInRange
	localLib=cdll.LoadLibrary('lib/nvdaHelperLocal.dll')
	for name,func in [
		("nvdaController_speakText",nvdaController_speakText),
		("nvdaController_cancelSpeech",nvdaController_cancelSpeech),
		("nvdaController_brailleMessage",nvdaController_brailleMessage),
		("nvdaControllerInternal_inputLangChangeNotify",nvdaControllerInternal_inputLangChangeNotify),
		("nvdaControllerInternal_displayModelTextChangeNotify",nvdaControllerInternal_displayModelTextChangeNotify),
		("nvdaControllerInternal_logMessage",nvdaControllerInternal_logMessage),
	]:
		try:
			_setDllFuncPointer(localLib,"_%s"%name,func)
		except AttributeError:
			log.error("nvdaHelperLocal function pointer for %s could not be found, possibly old nvdaHelperLocal dll"%name)
	localLib.startServer()
	generateBeep=localLib.generateBeep
	generateBeep.argtypes=[c_char_p,c_float,c_uint,c_ubyte,c_ubyte]
	generateBeep.restype=c_uint
	# Handle VBuf_getTextInRange's BSTR out parameter so that the BSTR will be freed automatically.
	VBuf_getTextInRange = CFUNCTYPE(c_int, c_int, c_int, c_int, POINTER(BSTR), c_int)(
		("VBuf_getTextInRange", localLib),
		((1,), (1,), (1,), (2,), (1,)))
	#Load nvdaHelperRemote.dll but with an altered search path so it can pick up other dlls in lib
	h=windll.kernel32.LoadLibraryExW(os.path.abspath(ur"lib\nvdaHelperRemote.dll"),0,0x8)
	if not h:
		log.critical("Error loading nvdaHelperRemote.dll: %s" % WinError())
		return
	_remoteLib=CDLL("nvdaHelperRemote",handle=h)
	if _remoteLib.injection_initialize(globalVars.appArgs.secure) == 0:
		raise RuntimeError("Error initializing NVDAHelperRemote")
	if os.environ.get('PROCESSOR_ARCHITEW6432')=='AMD64':
		_remoteLoader64=RemoteLoader64()
	winEventHookID=winUser.setWinEventHook(EVENT_TYPEDCHARACTER,EVENT_TYPEDCHARACTER,0,winEventCallback,0,0,0)
Esempio n. 4
0
def initialize():
	global accPropServices
	try:
		accPropServices=comtypes.client.CreateObject(CAccPropServices)
	except (WindowsError,COMError) as e:
		log.debugWarning("AccPropServices is not available: %s"%e)
	for eventType in winEventIDsToNVDAEventNames.keys():
		hookID=winUser.setWinEventHook(eventType,eventType,0,cWinEventCallback,0,0,0)
		if hookID:
			winEventHookIDs.append(hookID)
		else:
			log.error("initialize: could not register callback for event %s (%s)"%(eventType,winEventIDsToNVDAEventNames[eventType]))
def initialize():
	global accPropServices
	try:
		accPropServices=comtypes.client.CreateObject(CAccPropServices)
	except (WindowsError,COMError) as e:
		log.debugWarning("AccPropServices is not available: %s"%e)
	for eventType in winEventIDsToNVDAEventNames:
		hookID=winUser.setWinEventHook(eventType,eventType,0,cWinEventCallback,0,0,0)
		if hookID:
			winEventHookIDs.append(hookID)
		else:
			log.error("initialize: could not register callback for event %s (%s)"%(eventType,winEventIDsToNVDAEventNames[eventType]))
Esempio n. 6
0
def initialize(processDestroyWinEventFunc: Callable[[
    c_int,  # window
    c_int,  # objectID
    c_int,  # childID
], None]):
    global _processDestroyWinEvent
    _processDestroyWinEvent = processDestroyWinEventFunc
    for eventType in winEventIDsToNVDAEventNames:
        hookID = winUser.setWinEventHook(eventType, eventType, 0,
                                         cWinEventCallback, 0, 0, 0)
        if hookID:
            winEventHookIDs.append(hookID)
        else:
            log.error(
                f"initialize: could not register callback for"
                f" event {eventType} ({winEventIDsToNVDAEventNames[eventType]})"
            )
def requestWSRShowHideEvents(fn=None):
	global requestedWSRShowHideEvents, hookId, eventCallback, wsrPanelHiddenFunction
	if fn is None:
		fn = wsrPanelHiddenFunction
	else:
		wsrPanelHiddenFunction = fn
	if requestedWSRShowHideEvents:
		return
	try:
		hwnd = winUser.FindWindow(u"MS:SpeechTopLevel", None)
	except:
		hwnd = None
	if hwnd:
		pid, tid = winUser.getWindowThreadProcessID(hwnd)
		eventHandler.requestEvents(eventName='show', processId=pid, windowClassName='#32770')
		eventCallback = make_callback(fn)
		hookId = winUser.setWinEventHook(winUser.EVENT_OBJECT_HIDE, winUser.EVENT_OBJECT_HIDE, 0, eventCallback, pid, 0, 0)
		requestedWSRShowHideEvents = True
Esempio n. 8
0
def requestWSRShowHideEvents(fn=None):
	global requestedWSRShowHideEvents, hookId, eventCallback, wsrPanelHiddenFunction
	if fn is None:
		fn = wsrPanelHiddenFunction
	else:
		wsrPanelHiddenFunction = fn
	if requestedWSRShowHideEvents:
		return
	try:
		hwnd = winUser.FindWindow(u"MS:SpeechTopLevel", None)
	except:
		hwnd = None
	if hwnd:
		pid, tid = winUser.getWindowThreadProcessID(hwnd)
		eventHandler.requestEvents(eventName='show', processId=pid, windowClassName='#32770')
		eventCallback = make_callback(fn)
		hookId = winUser.setWinEventHook(win32con.EVENT_OBJECT_HIDE, win32con.EVENT_OBJECT_HIDE, 0, eventCallback, pid, 0, 0)
		requestedWSRShowHideEvents = True
Esempio n. 9
0
def connectConsole(obj):
	global consoleObject, consoleOutputHandle, checkDeadTimer
	#Get the process ID of the console this NVDAObject is fore
	processID,threadID=winUser.getWindowThreadProcessID(obj.windowHandle)
	#Attach NVDA to this console so we can access its text etc
	try:
		wincon.AttachConsole(processID)
	except WindowsError as e:
		log.debugWarning("Could not attach console: %r"%e)
		return False
	wincon.SetConsoleCtrlHandler(_consoleCtrlHandler,True)
	consoleOutputHandle=winKernel.CreateFile(u"CONOUT$",winKernel.GENERIC_READ|winKernel.GENERIC_WRITE,winKernel.FILE_SHARE_READ|winKernel.FILE_SHARE_WRITE,None,winKernel.OPEN_EXISTING,0,None)                                                     
	#Register this callback with all the win events we need, storing the given handles for removal later
	for eventID in (winUser.EVENT_CONSOLE_CARET,winUser.EVENT_CONSOLE_UPDATE_REGION,winUser.EVENT_CONSOLE_UPDATE_SIMPLE,winUser.EVENT_CONSOLE_UPDATE_SCROLL,winUser.EVENT_CONSOLE_LAYOUT):
		handle=winUser.setWinEventHook(eventID,eventID,0,consoleWinEventHook,0,0,0)
		if not handle:
			raise OSError("could not register eventID %s"%eventID)
		consoleWinEventHookHandles.append(handle)
	consoleObject=obj
	checkDeadTimer=gui.NonReEntrantTimer(_checkDead)
	checkDeadTimer.Start(CHECK_DEAD_INTERVAL)
	return True