moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

simulating mouse drag causes weird behaviors/delay. #428

Open MahdeenSky opened 2 years ago

MahdeenSky commented 2 years ago

At times it wouldn't even register a click on the browser, and the attempt at simulating drag has weird effects, like it doesn't release before it goes into the next drag movement, ending up dragging from X2 to the X1 of the next drag call.

        def click(self, New_X: int, New_Y: int):
        self.mouse.position = (New_X, New_Y)
        time.sleep(5*delay)
        self.mouse.click(Button.left)
        time.sleep(delay)

    def drag(self, X1: int, X2: int, Y: int):
        self.mouse.position = (X1, Y)
        self.mouse.press(Button.left)
        time.sleep(0.5)
        self.mouse.position = (X2, Y)
        self.mouse.release(Button.left)
        time.sleep(0.5)

OS: MacOS M1