def Position(self): location = Execute(["xdotool", "getmouselocation", "--shell"]) lines = location.split("\n") x, y, window = lines[0], lines[1], lines[3] x = x.replace("X=", "") y = y.replace("Y=", "") window = window.replace("WINDOW=", "") return (int(x), int(y), window)
def DragTo(self, FromX, FromY, ToX, ToY): current_x, current_y, _ = self.Position() Execute( [ "xdotool", "mousemove", "--window", self.Window, str(FromX), str(FromY), "mousedown", "--window", self.Window, "1", "mousemove", "--window", self.Window, str(ToX), str(ToY), "mouseup", "--window", self.Window, "1", "mousemove", str(current_x), str(current_y), ] )
def Click(self, X, Y, click_type=1): current_x, current_y, _ = self.Position() Execute( [ "xdotool", "mousemove", "--window", self.Window, str(X), str(Y), "click", "--window", self.Window, str(click_type), "mousemove", str(current_x), str(current_y), ] )
def __init__(self, FileName="images/tmp_screen.png"): Execute(["scrot", "-u", FileName]) self.TakedImage = cv2.imread(FileName) if self.TakedImage is not None: self.result = 1
def KeyUp(self, key): Execute(["xdotool", "keyup", key])
def KeyDown(self, key): Execute(["xdotool", "keydown", key])
def Press(self, key): Execute(["xdotool", "key", "--window", self.Window, key])
def MoveMouse(self, X, Y): Execute( ["xdotool", "mousemove", "--window", self.Window, str(X), str(Y), ] )