def _run(self): if vision._isDebug(): log.debug("Starting NVDAHighlighter thread") window = self.window = self.customWindowClass(self) self.timer = winUser.WinTimer(window.handle, 0, self.refreshInterval, None) msg = MSG() while winUser.getMessage(byref(msg), None, 0, 0): winUser.user32.TranslateMessage(byref(msg)) winUser.user32.DispatchMessageW(byref(msg)) if vision._isDebug(): log.debug("Quit message received on NVDAHighlighter thread") if self.timer: self.timer.terminate() self.timer = None if self.window: self.window.destroy() self.window = None
def _run(self): try: if vision._isDebug(): log.debug("Starting NVDAHighlighter thread") window = self._window = self.customWindowClass(self) timer = winUser.WinTimer(window.handle, 0, self._refreshInterval, None) self._highlighterRunningEvent.set() # notify main thread that initialisation was successful msg = MSG() # Python 3.8 note, Change this to use an Assignment expression to catch a return value of -1. # See the remarks section of # https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage while winUser.getMessage(byref(msg), None, 0, 0) > 0: winUser.user32.TranslateMessage(byref(msg)) winUser.user32.DispatchMessageW(byref(msg)) if vision._isDebug(): log.debug("Quit message received on NVDAHighlighter thread") timer.terminate() window.destroy() except Exception: log.exception("Exception in NVDA Highlighter thread")