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")
def __init__(self, highlighter): if vision._isDebug(): log.debug("initializing NVDAHighlighter window") super().__init__(windowName=self.windowName, windowStyle=self.windowStyle, extendedWindowStyle=self.extendedWindowStyle) self.location = None self.highlighterRef = weakref.ref(highlighter) winUser.SetLayeredWindowAttributes( self.handle, self.transparentColor, self.transparency, winUser.LWA_ALPHA | winUser.LWA_COLORKEY) self.updateLocationForDisplays() if not winUser.user32.UpdateWindow(self.handle): raise WinError()
def updateLocationForDisplays(self): if vision._isDebug(): log.debug("Updating NVDAHighlighter window location for displays") displays = [ wx.Display(i).GetGeometry() for i in range(wx.Display.GetCount()) ] screenWidth, screenHeight, minPos = getTotalWidthAndHeightAndMinimumPosition( displays) # Hack: Windows has a "feature" that will stop desktop shortcut hotkeys from working # when a window is full screen. # Removing one line of pixels from the bottom of the screen will fix this. left = minPos.x top = minPos.y width = screenWidth height = screenHeight - 1 self.location = RectLTWH(left, top, width, height) winUser.user32.ShowWindow(self.handle, winUser.SW_HIDE) if not winUser.user32.SetWindowPos(self.handle, winUser.HWND_TOPMOST, left, top, width, height, winUser.SWP_NOACTIVATE): raise WinError() winUser.user32.ShowWindow(self.handle, winUser.SW_SHOWNA)