I used lots of different source codes, and even copied and pasted but I keep getting random symbols that shift when i move my mouse over them here is my code...
import pyautogui, time, sys
print('Press Ctrl-C to quit.')
try:
while True:
CurserPos = pyautogui.position()
print('\b' * len(CurserPos), end='\r')
sys.stdout.flush()
I will show the output as an image. I am rather new to Python and would really appreciate some expert advice. Thanks
How do I get the mouse position in Python using Pyautogui? To determine the mouse's current position, we use the statement, pyautogui. position(). This function returns a tuple of the position of the mouse's cursor.
How do you find XY coordinates on a mouse? It can be find using the clientX and clientY property: ClientX: It gives the horizontal coordinate of the event. ClientY: It gives the vertical coordinate of the mouse.
Once you're in Mouse settings, select Additional mouse options from the links on the right side of the page. In Mouse Properties, on the Pointer Options tab, at the bottom, select Show location of pointer when I press the CTRL key, and then select OK. To see it in action, press CTRL.
This code will print the live position of your mouse after every one second.
import pyautogui as py #Import pyautogui
import time #Import Time
while True: #Start loop
print (py.position())
time.sleep(1)
Pyautogui can programmatically control the mouse & keyboard.
More information about it can be found here https://pypi.org/project/PyAutoGUI/
Code :
import pyautogui
pyautogui.displayMousePosition()
Here is some output :
Press Ctrl-C to quit.
X: 0 Y: 1143 RGB: ( 38, 38, 38)
Here is the video where this is being demonstrated https://youtu.be/dZLyfbSQPXI?t=809
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With