Advertisement
mengyuxin

mouse_now.py

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