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
def event_NVDAObject_init(self, obj): global hwndWinamp hwndWinamp = winUser.FindWindow("Winamp v1.x", None)
# The process is refusing to exit gracefully, so kill it forcefully. h = winKernel.openProcess( winKernel.PROCESS_TERMINATE | winKernel.SYNCHRONIZE, False, processID) if not h: raise OSError("Could not open process for termination") try: winKernel.TerminateProcess(h, 1) winKernel.waitForSingleObject(h, 2000) finally: winKernel.closeHandle(h) #Handle running multiple instances of NVDA try: oldAppWindowHandle = winUser.FindWindow(u'wxWindowClassNR', u'NVDA') except: oldAppWindowHandle = 0 if not winUser.isWindow(oldAppWindowHandle): oldAppWindowHandle = 0 if oldAppWindowHandle and not globalVars.appArgs.easeOfAccess: if globalVars.appArgs.check_running: # NVDA is running. sys.exit(0) try: terminateRunningNVDA(oldAppWindowHandle) except: sys.exit(1) if globalVars.appArgs.quit or (oldAppWindowHandle and globalVars.appArgs.easeOfAccess): sys.exit(0)