2
I would like to make a program that indicates to which position the mouse is moving (right, left, high, low, right and high, right and low...), but I can’t get a logic that gives me this result.
Examples are: If the Y and X are being incremented, then the mouse will be going up and right at the same time. If only X is being incremented, then the mouse is going right. If X is being decremented, the mouse is going left. And so on and so forth.
I’ve thought of many ways, but nothing works.
import pynput
def Position():
mouse = pynput.mouse.Controller()
while True:
position_anterior = mouse.position[0] #mouse.position retorna uma tupla com (x, y)
position_atual = mouse.position[0]
if position_atual > position_anterior: #
print("direita")
elif position_atual < position_anterior:
print("esquerda")
elif position_atual == position_anterior:
print("parado")
Position()