summaryrefslogtreecommitdiff
path: root/Chap18ProjMouseNow.py
blob: 7567748005575ada4bd59867dd37f294c8851d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! python3

# Chapter 18 Project Where is the Mouse Right Now?
# Displays the mouse cursor's current postion

import pyautogui

print('Press Ctrl-C to quit.')
try:
    while True:
        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.')