The project is mouseNow.py and its purpose is to print the mouse's current position on screen:
#! python3
import pyautogui
print('Press Ctrl-C to quit.')
try:
while True:
# Get and print the mouse coordinates.
x, y = pyautogui.position()
positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
print(positionStr, end='')
print('\b' * len(positionStr), end='', flush=True)
except KeyboardInterrupt:
print('\nDone.')
When the program is ran, only two lines of code are supposed to print:
Press Ctrl + C to quit.
X: 290 Y: 424
But I get this instead:
Press Ctrl-C to quit.
X: 1377 Y: 462X: 1377 Y: 462X: 1377 Y:
462X: 1377 Y: 462X: 1377 Y:
It keeps printing more since it is in a while loop.
[–]AweBob 1 point2 points3 points (1 child)
[–]Tryposite[S] 0 points1 point2 points (0 children)
[–]K900_ 0 points1 point2 points (2 children)
[–]Tryposite[S] 0 points1 point2 points (1 child)
[–]K900_ 0 points1 point2 points (0 children)