Is there a way to constantly get my mouse position and print it with Python? I know that with Tkinter you can achieve that by binding mouse motion with something like this, but i want something that also works outside of Tkinter created windows
def motion(event):
posx, posy = pyautogui.position()
print("PosX = " + str(posx) + " PosY = " + str(posy))
root.bind('<Motion>', motion)
Edit: Thanks for the answers but i wasn't so clear in my question, i need a way it works on background while i can use other methods on my code. If i use while True i will be locked within this method. I need something exactly like root.bind('<Motion>', motion)
but that works outside of root window, for example.