diff options
Diffstat (limited to 'Chap18ProjMouseNow.py')
-rw-r--r-- | Chap18ProjMouseNow.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Chap18ProjMouseNow.py b/Chap18ProjMouseNow.py new file mode 100644 index 0000000..7567748 --- /dev/null +++ b/Chap18ProjMouseNow.py @@ -0,0 +1,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.') |