def _getPointFromOffset(self, offset): # Returns physical coordinates. rects=self._storyFieldsAndRects[1] if not rects or offset>=len(rects): raise LookupError x,y=rects[offset][:2] x,y=windowUtils.logicalToPhysicalPoint(self.obj.windowHandle,x,y) return textInfos.Point(x, y)
def _setCaretOffset(self, offset): rects = self._storyFieldsAndRects[1] if offset >= len(rects): raise RuntimeError("offset %d out of range") left, top, right, bottom = rects[offset] x = left #+(right-left)/2 y = top + (bottom - top) / 2 x, y = windowUtils.logicalToPhysicalPoint(self.obj.windowHandle, x, y) winUser.setCursorPos(x, y) winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None) winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
def _setCaretOffset(self,offset): rects=self._storyFieldsAndRects[1] if offset>=len(rects): raise RuntimeError("offset %d out of range") rect = rects[offset] x = rect.left y= rect.center.y x,y=windowUtils.logicalToPhysicalPoint(self.obj.windowHandle,x,y) oldX,oldY=winUser.getCursorPos() winUser.setCursorPos(x,y) mouseHandler.doPrimaryClick() winUser.setCursorPos(oldX,oldY)
def _setCaretOffset(self,offset): rects=self._storyFieldsAndRects[1] if offset>=len(rects): raise RuntimeError("offset %d out of range") left,top,right,bottom=rects[offset] x=left #+(right-left)/2 y=top+(bottom-top)/2 x,y=windowUtils.logicalToPhysicalPoint(x,y) oldX,oldY=winUser.getCursorPos() winUser.setCursorPos(x,y) winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None) winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None) winUser.setCursorPos(oldX,oldY)
def _setCaretOffset(self,offset): rects=self._storyFieldsAndRects[1] if offset>=len(rects): raise RuntimeError("offset %d out of range") rect = rects[offset] x = rect.left y= rect.center.y x,y=windowUtils.logicalToPhysicalPoint(self.obj.windowHandle,x,y) oldX,oldY=winUser.getCursorPos() winUser.setCursorPos(x,y) mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN,0,0) mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP,0,0) winUser.setCursorPos(oldX,oldY)
def toPhysical(self, hwnd): """Converts self from logical to physical coordinates and returns a new L{Point}""" return Point(*windowUtils.logicalToPhysicalPoint(hwnd, *self))