Closed FaeyzaNursandy closed 3 years ago
input
returns a string, while mouse.position
is a tuple of integers, for example (100, 200)
. You will need to parse the input into a tuple of integers.
For example, you could do:
# Get input, split the string into 2 variables where a comma is encountered
mouse_x, mouse_y = input("Enter mouse position here!").split(',')
# Remove whitespace of the strings, convert them to integers, then assign it as a tuple
mouse.position = (int(mouse_x.strip()), int(mouse_y.strip()))
Alternatively you could utilize map
, but this is not the most reader-friendly:
mouse.position = tuple(map(lambda x: int(x.strip()), input("Enter mouse position here!").split(',')))
I use this code but the pointer moved to 0, 0
from pynput.mouse import Button, Controller mouse = Controller() mousepos= input("Enter mouse position here!") mouse.position = mousepos