Home > Enterprise >  Can I get the mouse position with a different format
Can I get the mouse position with a different format

Time:04-19

I am trying to get the position of my mouse, but make it print just the coordinates like

1000, 1000

Not like

Point(x=1212, y=621)

My Code:


x = pyautogui.position()

CodePudding user response:

You can use

x, y = pyautogui.size()
print(x)
print(y)

CodePudding user response:

You can do it in this way:

import pyautogui

x,y = pyautogui.position()
print(f"x:{x}, y:{y}")

Output:

x:479, y:441

If you don't want x and y to appear then you can use:

import pyautogui

x,y = pyautogui.position()
print(x, y)

Output:

479, 441
  • Related