def SetWindowPosAndSize(self): x1 = self.spinOffsetX.GetValue() y1 = self.spinOffsetY.GetValue() w = self.spinW.GetValue() h = self.spinH.GetValue() x2 = x1 + w y2 = y1 + h try: progName, title = make_tuple(self.cboxWindow.GetValue()) except: return kwargs = self.GetMatchKwargs() handles = winman.GetHandles(progName, title, **kwargs) if not handles: return for handle in handles: try: winman.MoveWindow(handle, x1, y1, w, h) except Exception as e: print(e) return self.Raise()
def MouseClickAbsolute(kwargs): progName, title = make_tuple(kwargs["window"]) handles = winman.GetHandles(progName, title, **kwargs) x1, y1, w, h = kwargs["offsetx"], kwargs["offsety"], kwargs["width"], kwargs["height"] x, y = int(kwargs["x"]), int(kwargs["y"]) for handle in handles: winman.RestoreWindow(handle) if kwargs["resize"] is True: winman.MoveWindow(handle, x1, y1, w, h) winman.SetForegroundWindow(handle) winman.LeftMouseClick(x, y)
def CloseWindow(kwargs): """ Get handles and their respective titles. If condition is matched, try to close window by handle """ progName, title = make_tuple(kwargs["window"]) handles = winman.GetHandles(progName, title, **kwargs) print("handles", handles) for handle in handles: winman.CloseWindow(handle) return
def GetWindowRect(self): try: progName, title = make_tuple(self.cboxWindow.GetValue()) except: return kwargs = self.GetMatchKwargs() handles = winman.GetHandles(progName, title, **kwargs) if not handles: return for handle in handles: x1, y1, x2, y2 = winman.GetWindowRect(handle) return x1, y1, x2, y2
def MouseClickRelative(kwargs): progName, title = make_tuple(kwargs["window"]) handles = winman.GetHandles(progName, title, **kwargs) x1, y1, w, h = kwargs["offsetx"], kwargs["offsety"], kwargs["width"], kwargs["height"] x, y = x1 + int(kwargs["%width"] * w * 0.01), y1 + int(kwargs["%height"] * h * 0.01) for handle in handles: winman.RestoreWindow(handle) winman.SetForegroundWindow(handle) if kwargs["resize"] is True: winman.MoveWindow(handle, x1, y1, w, h) else: # calculate new relative positon x1, y1, w, h = winman.GetWindowRect(handle) x, y = x1 + int(kwargs["%width"] * w * 0.01), y1 + int(kwargs["%height"] * h * 0.01) winman.LeftMouseClick(x, y)
def GetWindowRect(self): try: progName, title = make_tuple(self.cboxWindow.GetValue()) except: return kwargs = { "matchcondition": self.cboxMatch.GetSelection(), "matchcase": self.chkMatchTitleCase.GetValue(), "matchstring": self.chkMatchTitle.GetValue(), "matches": self.cboxMatches.GetValue(), } handles = winman.GetHandles(progName, title, **kwargs) if not handles: return for handle in handles: x1, y1, x2, y2 = winman.GetWindowRect(handle) return x1, y1, x2, y2
def FindWindow(kwargs): progName, title = make_tuple(kwargs["window"]) if winman.GetHandles(progName, title, **kwargs) == []: return False return True