Advertisement
mengyuxin

get_mouse.py

Jan 14th, 2018
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1.   1 #!/usr/bin/python
  2.   2 # get_mouse.py - Displays the mouse cursor's current positions.
  3.   3
  4.   4 import pyautogui
  5.   5
  6.   6 print('Press Ctrl+C to quite.')
  7.   7
  8.   8 # Get and print the mouse coordinates.
  9.   9 try:
  10.  10     while True:
  11.  11         x, y = pyautogui.position()
  12.  12         postion_str = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
  13.  13         print(postion_str, end='')
  14.  14         print('\b' * len(postion_str), end='', flush = True)
  15.  15 except KeyboardInterrupt:
  16.  16     print('\nDone.')
  17. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement