How to use the pynput.mouse.Button function in pynput

To help you get started, we’ve selected a few pynput examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AirtestProject / deval / deval / component / linux / input.py View on Github external
def swipe(self, p1, p2, duration=0.5, steps=5, fingers=1, button='left'):
        if button is "middle":
            button = Button.middle
        elif button is "right":
            button = Button.right
        elif button is "left":
            button = Button.left
        else:
            raise ValueError("Unknow button: " + button)
        x1, y1 = p1
        x2, y2 = p2
        x1 = x1 + self.monitor["left"]
        x2 = x2 + self.monitor["left"]
        y1 = y1 + self.monitor["top"]
        y2 = y2 + self.monitor["top"]
        ratio_x = self.monitor["width"] / self.singlemonitor["width"]
        ratio_y = self.monitor["height"] / self.singlemonitor["height"]
        x2 = x1 + (x2 - x1) / ratio_x
        y2 = y1 + (y2 - y1) / ratio_y
github ipaleka / arrangeit / tests / functional / arrangeit_keywords.py View on Github external
def release_cursor():
    mouse = Controller()
    mouse.press(Button.middle)
    mouse.release(Button.middle)
github becurrie / titandash / titanbot / titandash / bot / core / tester.py View on Github external
def on_click(x, y, button, pressed):
        global clicks
        if pressed and button == Button.left:
            clicks.append((x, y))
        if pressed and button == Button.right:
            print("CLICKS:")
            for click in clicks:
                print(click)

            # Reset clicks list to blank.
            clicks = []
github nimaid / LPHK / ms.py View on Github external
def release(button="left"):
    _check_button(button)
    controller.release(Button[button])
github the-vishal / Air-Mouse / Air_Mouse.py View on Github external
y = sauce.find('accelerometer2')
    Y = int(float(y.text))
    #z = sauce.find('accelerometer3')
    #Z = int(float(z.text))
    #print(X)
    #print(Y)
    #Pythagoras Theorem for 3rd axis
    #h1 = int(math.sqrt(X**2 + Z**2))
    #h2 = int(math.sqrt(Y**2 + Z**2))
    single_click = sauce.find('lightintensity')
    mouse.move(-X*4,-Y*4)
    
    #left click
    if int(float(single_click.text)) <= 10:
        mouse.click(Button.left)
        mouse.release(Button.left)
        #print("Right Click")
github mozilla / iris / moziris / api / mouse / mouse_controller.py View on Github external
def release(
        self,
        location: Location = None,
        duration: float = None,
        button: Button = Button.left,
    ):
        """Mouse press.

        :param location: Mouse press location.
        :param duration: Speed of mouse movement from current mouse location to target.
        :param button: 'left','right' or 'middle'.
        :return: None
        """
        self.move(location, duration)
        self.mouse.release(button)
github HBRYU / Picaso_bot / Picaso.py View on Github external
grayThresh += threshStep		#After it scanned through the whole image, increase max rgb value (grayThresh)
									#by threshStep
	
	print("GrayThresh :", grayThresh)
	
	#	<>
	# All delays (time.sleep) are needed for ms paint to register the mouse / keyboard actions
	# They can be shortened
	
	mouse.position = (1030, 80)		#SELECT COLOR Button pixel coordinates
	mouse.click(Button.left, 1)
	time.sleep(0.5)
	
	mouse.position = (1200, 600)	#SELECT COLOR\RED Button pixel coordinates
	mouse.click(Button.left, 1)
	time.sleep(0.05)
	keyboard.press(Key.backspace)
	time.sleep(0.05)
	keyboard.press(Key.backspace)
	time.sleep(0.05)
	keyboard.press(Key.backspace)
	time.sleep(0.05)
	keyboard.press(Key.delete)
	time.sleep(0.05)
	keyboard.press(Key.delete)
	time.sleep(0.05)
	keyboard.press(Key.delete)
	time.sleep(0.05)
	keyboard.type(str(grayThresh))	#Enter the max rgb value (grayThresh) in COLOR\RED
	
	mouse.position = (1200, 630)	#SELECT COLOR\BLUE Button pixel coordinates